Rajendra Dharmkar has Published 452 Articles

How we can extend multiple Python classes in inheritance?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

352 Views

As per Python documentation ‘super’ can help in extending multiple python classes in inheritance.  It returns a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. The search order is same ... Read More

What is difference between '.' , '?' and '*' in Python regular expression?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

300 Views

Special character dot '.'(Dot.) In the default mode, this matches any character except a newline. If the DOTALL flag has been specified, this matches any character including a newline.Special character '?'Causes the resulting RE to match 0 or 1 repetitions of the preceding RE. ab? will match either ‘a’ or ... Read More

How to compare regular expressions in Perl and Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

257 Views

The most basic regex features are nearly the same in nearly every implementation: wild character ., quantifiers *, +, and ?, anchors ^ and $, character classes inside [], and back references \1, \2, \3etc.Alternation is denoted | in Perl and PythonPerl and Python will let you modify a regular ... Read More

How to capture an exception raised by a Python Regular expression?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

878 Views

When the match method is implemented, if it turns out that there are no matches, then None is returned. There are no functions in the re module that throw up an exception when the list or matches is emptyexception re.errorException raised when a string passed to one of the functions ... Read More

How can I find all matches to a regular expression in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

103 Views

We use re.findall or re.finditer methods to find all matches to a regular method.re.findall(pattern, string) returns a list of matching strings.re.finditer(pattern, string) returns an iterator over MatchObject object

How do you compare Python objects with .NET objects?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

125 Views

By default, all .NET objects are reference types and their equality and hash code is determined by their memory address. Additionally, assigning a variable to an existing object just makes it point to that address in memory, so there is no costly copying occurring. It appears that this is true ... Read More

How to compress Python objects before saving to cache?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

243 Views

We need sometimes to compress Python objects (list, dictionary, string, etc) before saving them to cache and decompress after reading from cache.Firstly we need to be sure we need to compress the objects. We should check if  the data structures/objects are too big just to fit uncompressed in the cache. ... Read More

Do you think garbage collector can track all the Python objects?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

112 Views

Python uses two techniques to clean up garbage. One is reference counting, which affects all objects but which can't clean up objects that directly or indirectly refer to each other. That's where the actual garbage collector comes in: python has the gc module, which searches for cyclic references in objects ... Read More

When are python objects candidates for garbage collection?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

191 Views

A python object or variable will be eligible for garbage collection as soon as all references to it go out of scope or are manually deleted (del x). We would have to presume there were no references to the object anywhere else for it to be garbage collected.

How does nested character class subtraction work in Python?

Rajendra Dharmkar

Rajendra Dharmkar

Updated on 30-Jul-2019 22:30:21

308 Views

Nested Character Class SubtractionSince we can use the full character class syntax within the subtracted character class, we can subtract a class from the class being subtracted. [0-9-[0-7-[0-3]]] first subtracts 0-3 from 0-7, yielding [0-9-[4-7]], or [0-38-9], which matches any character in the string 012389.The class subtraction is always the ... Read More

Advertisements