Python Notes
22 articles in this category.
- All
- Python 133
- Tools 30
- Tutorials 20
- DATABASE 10
- PHP 8
- C & C++ 5
- Java 4
- Web Development 2
- General Blogs 1
-
Python OOP part 4: abstract classes, interfaces, private members and __str__
Finish the object-oriented basics: abstract methods and classes with abc, interfaces, public, protected and private members, name mangling, __str__ versus __repr__, and a small banking application that uses them all, with tested output.
-
Python OOP part 3: polymorphism, duck typing and operator overloading
Polymorphism in Python explained with tested code: duck typing, method overriding, operator overloading with magic methods, method and constructor overloading (and what Python does instead), and when to use each.
-
Python OOP part 2: inheritance, has-a vs is-a, MRO and super()
Reuse code with inheritance: the has-a and is-a relationships, composition versus aggregation, the five types of inheritance, cyclic inheritance, method resolution order (MRO), and how super() works, with tested output.
-
Python OOP part 1: classes, objects, self, constructors and variable types
Start object-oriented programming in Python: what a class and an object are, self, the constructor, instance, class and local variables, instance, class and static methods, garbage collection and destructors, with tested output.
-
Python dictionaries: keys, values, methods and comprehensions
A practical guide to the Python dict: creating dictionaries, reading, adding, updating and deleting keys, get and setdefault, looping with items, merging, nested data, counting with Counter and dictionary comprehensions, with tested output.
-
Python exception handling: try, except, else, finally, raise and assert
Handle errors in Python properly: syntax errors versus exceptions, the exception hierarchy, try/except/else/finally and their control flow, handling several exceptions, raising and defining your own, logging and assertions, with tested output.
-
Python file handling: open, read, write, with, CSV, zip and pickle
How to work with files in Python: text and binary files, open() modes, reading and writing, the with statement, file object properties, binary data, CSV files, zipping and unzipping, and pickling objects, with tested output.
-
Python flow control: if, for, while, break, continue and nested loops
How a Python program makes decisions and repeats work: if, elif and else, truthiness, for and while loops, range, break, continue, pass, loop else, infinite loops, nested loops and number patterns, with tested output.
-
Python functions: arguments, lambda, decorators and generators
A complete guide to Python functions: defining and calling them, the types of arguments, returning several values, scope and global, recursion, lambda with map, filter and reduce, nested functions, decorators and generators, with tested output.
-
Python input and output: input(), print(), sys.argv and formatting
How a Python program talks to the user: reading keyboard input with input(), converting types, reading several values, command-line arguments with sys.argv and argparse, and printing with sep, end, file and f-strings, with tested output.
-
Python lists: indexing, methods, sorting, copying and comprehensions
Everything about the Python list: creating and accessing items, mutability, looping, the important methods, append versus insert, remove versus pop, sorting, aliasing and copying, nested lists and comprehensions, with tested output.
-
Python modules: import styles, aliases, reload, random and __name__
What a Python module is and how to use one: the four import styles, module and member aliases, dir() and help(), reloading a changed module, the random module, and the special __name__ variable, with tested output.