Reading Time: 1 minutesPrettifying output in Python using pprint Prettifying output in Python using pprint The builtin pprint module enables the user to prettify the output while printing lists, tuples & dictionaries. This […]
Python
Getting help from Python: Using the builtin function help()
Reading Time: 1 minutesUsing help() in Python Using help() in Python Python's builtin help() function returns the description of the object passed to it, in addition to its basic usage. For example, if […]
Exploring an object in Python: Using the builtin function dir()
Reading Time: 1 minutesUsing dir() in Python Using dir() in Python The dir(object) function returns a list of all the methods and associated with the mentioned object. Everything in Python is an object, […]
Python: The "if __name__ == '__main__':" construct
Reading Time: 2 minutesif __name__ == '__main__' if __name__ == '__main__' You may have encountered something like if __name__ == '__main__'. This if construct is used to execute the top-level code(i.e. at the […]
Creating isolated Python environments using virtualenv
Reading Time: 4 minutesvirtualenv in Python virtualenv in Python Creating isolated Python environnments is a great industrial practice to keep two or more applications separate from each other. These applications have different dependencies, […]
Python: Replacing a method dynamically in a class
Reading Time: 5 minutesReplacing a method dynamically in Python Replacing a method dynamically in Python There are 3 ways to dynamically replace the contents of a method defined inside a class with contents […]
Python: Executing Python statements dynamically with compile(), exec() & eval()
Reading Time: 2 minutesExecuting statements dynamically with compile(), exec() & eval() in Python Executing statements dynamically with compile(), exec() & eval() in Python Python offers two builtin functions to execute pieces of code […]
Python: The builtin sorted() in detail
Reading Time: 1 minutessorted() in Python sorted() in Python You can use the command sorted(list1) to sort the elements of a list. You can give it a custom comparison function, and for more […]

