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. https://gist.github.com/anaved/437ed10fa2c2a4f3252e715aa2f2b006#file-file_read_in_context-py In this method, Read more…

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…

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.

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…