PythonZen

Keywords Description Example Tutorial
import this
if __name__ = "__main__" An idiom that is used if we want to make sure that certain code is executed only when it is directly run from the main program.
__name__ is a special-built-in variable. (Represents the main python program)
Coding/Python/attachments/Screenshot 2025-07-29 at 12.43.17.png
Everything entity we work on in Python is an instance of a class. Data-types, Classes, functions, modules Object Hierarchy
! 150
Indentation Indentation improves readability.
Statements like if, for, while, def, class are followed by a colon. This means the start of a code block needs to be indented.
Code inside the same block belongs to performs code inside that block only.
else clause inside loops. This is unrelated to conditional logic. It is related to no-break clause. Coding/Python/attachments/Screenshot 2025-07-29 at 12.53.21.png
List comprehension Unique way of creating loops, list and conditional in one line.
Multiple Assignment & Tuple unpacking A way of assigning multiple variables on a single line of code. Coding/Python/attachments/Screenshot 2025-07-29 at 12.57.09 1.png
Dynamic and strong typing Don't need to declare a variable type explicitly.
Variable type is determined at runtime
Coding/Python/attachments/Screenshot 2025-07-29 at 12.58.42.png
Duck Typing Does not constraints object by type and allows to declare different methods . Coding/Python/attachments/Screenshot 2025-07-29 at 13.00.39 1.png
pass Tells the program to do nothing. Can be declared as a placeholder
First class functions First-class functions allow functions to be used as a list, variable and used as arguments in other functions.
Function closure A closure is a function object that can use information from other functions/objects that enclose it.
args & kwargs 2 special syntax that allows the user to place an arbitrary number of arguments or inputs in functions.
args = Arbitrary positional arguments: Allows a function to take an arbitrary number of inputs.

kwargs = Arbitrary Keyword arguments : Inputs are key-value pairs
args

kwargs

Walrus Operator Assignment Expression:
Allows to assign values within a variable
Decorators A way to enhancing functions without altering its code. Used in functions, classes and methods.
Commonly used for timing, caching , and validation.
here
with and Context Managers Context Managers in Python act as a tool of resource management. It implements 2 special functions:
- __enter__ which setup the resources
- __exit__ which handles cleanup
Global Intrepreter Lock A Mutual-exclusion lock:
This states only one thread can access a part of a program at a time.

Frameworks

Django Web Development
FastAPI API Development
Pandas Data Analysis
Numpy Matrix Manipulation
Tensorflow Deep Learning
Sci-kit Learn Machine Learning
BeautifulSoap Web Scrapping
OvenCV Computer Vision
Matplotlib/Plotly Data Visualization
SqlAlchemy Database Management
PyGame Game Development
PySpark Big Data Processing
Powered by Forestry.md