Python

Context Managers In Python

Context managers are inherent feature of python to provide a way to obtain and release resources on demand. When a context manager is used, a definite scope is defined to safely delete or clean resources. For example a file can be read in below two ways. View the code on Read more…

By Naved, ago
Python

functools Module In Python

As per python docs “The functools module is for higher-order functions: functions that act on or return other functions.“ Partial Star of functoolsis certainly partial, which provides ability to set a subset of arguments expected by a function. This partially set function can now be passed to the next consumer Read more…

By Naved, ago
Python

Writing A Quicksort In Python

There are few ways we can write a quick sort algorithm in python. Following are few flavors to achieve this. Quick-Sort with First element as pivot View the code on Gist. Quick-Sort with Mid element as pivot View the code on Gist.

By Naved, ago
Python

Properties In Python

Properties in python are used to provide access methods to change an attribute of a class. By providing getter, setter, deleter methods, properties provide abstraction over the internal representation of the data. Property functions can range from data type validation, to any enrichment and calculation. By adding a @property decorator, Read more…

By Naved, ago