Python Revision - Section XI - Advanced Modules
Counter Counter is a dict subclass which helps count hashable objects. Inside of its elements are stored as dictionary keys and the counts of the objects are stored as the value. from collections...
Counter Counter is a dict subclass which helps count hashable objects. Inside of its elements are stored as dictionary keys and the counts of the objects are stored as the value. from collections...
Iterators Iterator is a general concept: an object whose class has a next() method is an iterator. Every generator is an iterator, but not vice versa. Generators Briefly, generators allow us to ...
Built-in Functions We’ve already seen some important built-in functions like map, filter and lambda. Now, we’ll see other ones. Reduce The function reduce(function, sequence) continually applies...
Decorators In a generic way, decorator is a design pattern that allows some behaviour to be added to an individual object, dynamically, without affecting the behaviour of other objects from the sa...
Pylint A library which checks the code for possible errors and styling. We can install it through pip install pylint and run it over a file with the command: pylint <file.py>. Unit Test I...
Modules In order to create a new module, we’ve just to create a new .py file with the module name and then import it using the Python file name using the import command. import foo Packages Pa...
Shell Script After losing some seconds copy-pasting and editing old files to creating new posts, I decided to automate this routine. #! /bin/bash # Check if the input is in the correct format if...
Object-Oriented Programming (OOP) is a programming paradigm based on the concept of objects. Each object is an instance of a class. Each class is defined by its attributes and its methods. Attribut...
Map Function The map function allows us to map a function to an iterable object. def square(num): return num**2 my_nums = [1,2,3,4] map(square, my_nums) To obtain the mapp...
*args When a function parameter starts with an asterisk, it allows for an arbitrary number of arguments, and the function takes them in as a tuple of values. def myfunc(*args): return sum(arg...