{"id":17683198,"url":"https://github.com/nemanjam/python-overview","last_synced_at":"2025-10-04T02:12:34.984Z","repository":{"id":102334863,"uuid":"570495026","full_name":"nemanjam/python-overview","owner":"nemanjam","description":"Python language overview.","archived":false,"fork":false,"pushed_at":"2022-11-28T12:43:35.000Z","size":7,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-09-08T09:48:27.954Z","etag":null,"topics":["cheatsheet","python"],"latest_commit_sha":null,"homepage":"","language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nemanjam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-11-25T10:28:02.000Z","updated_at":"2022-11-25T10:42:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"459f871e-db6b-4735-a815-02435e4ed8cb","html_url":"https://github.com/nemanjam/python-overview","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nemanjam/python-overview","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fpython-overview","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fpython-overview/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fpython-overview/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fpython-overview/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nemanjam","download_url":"https://codeload.github.com/nemanjam/python-overview/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nemanjam%2Fpython-overview/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278254466,"owners_count":25956604,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-04T02:00:05.491Z","response_time":63,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cheatsheet","python"],"created_at":"2024-10-24T09:44:38.996Z","updated_at":"2025-10-04T02:12:34.968Z","avatar_url":"https://github.com/nemanjam.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# Python language overview\n\nNotes from [_\"Core Python learning path\"_](https://www.pluralsight.com/paths/core-python) - on Pluralsight.\n\n- _\"Big Picture\"_ - by Jason Olson\n- _\"Core Python 3: Getting-Started\"_\n- _\"Python 3: Beyond the Basics\"_\n- _\"Advanced Python\"_ - all 3 by Austin Bingham and Robert Smallshire\n- _\"Managing Python Packages and Virtual Environments\"_\n- _\"Python Best Practices for Code Quality\"_ - by Reindert-Jan Ekker\n\n---\n\n### Big Picture\n\n#### Why Python?\n\n#### What is Python?\n\nPython is general purpose, multi-paradigm, interpreted, garbage collected, dynamically typed language with comprehensive standard library, \n\n#### Python Pros and Cons\n\n---\n\n### Getting Started\n\n#### Installing and Starting Python\n\n#### Scalar Types, Operators, and Control Flow\n\n_scalar types_ - all immutable, int, float, None, bool, _control flow_ - if, else, elif, _loops_ - while, for, _relational operators_, _and, or, not_ - logical operators, _in_ - membership operator, _is_ - identity operator, \n\n#### Introducing Strings, Collections, and Iteration\n\n_str_ - immutable string type and literals, _bytes_ - binary type, encoding and literals, \n\n#### Modularity\n\n_modules_ - .py files, _\\_\\_name\\_\\_ attribute_ - detect if file is imported or executed in shell, _python execution model_ - function name is bound to definition at runtime, _sys.argv[...]_ - passing command line arguments, _main()_ - custom entry point for a python script, _shebang_ - run python file as shell script, _docstrings_ - singleline and multiline, \n\n#### Objects and Types\n\n_object and type models_, _identity equality_ - defined on language level, _value equality_ - defined on type level, _all variables are references, not boxes_ - all variables including scalar types, _pass by reference_ - arguments and return values, _positional and keyword arguments_ - defined on invocation, _default arguments_ - called at bind time, must be immutable types, _strong, dynamic type system_ - types resolved at runtime,  no type coercion to match type, _4 levels scope - LEGB_ - local, enclosing, global, built in, _everything is an object_ - including scalar types, functions and modules, \n\n#### Built-in Collections\n\n_built in collections_, _list [...]_ - mutable, indexed, ordered collection with duplicates, _tuple (...)_ - immutable, indexed, ordered collection with duplicates, _ranges_ - arithmetic progression of integers, _dictionary {key: val}_ - unordered, indexed, mutable collection without duplicates - associative array - JavaScript object equivalent, _set {...}_ - unordered, non-indexed, mutable collection of immutable elements without duplicates, _protocols_ - set of functions, interface, \n\n#### Exceptions\n\n_try, except_ - exception handling, _raise_ - throwing exceptions, _finally_ - block for cleanup actions, _programmer errors_ - should not be handled, _exceptions are part of the function signature and protocols_, _EAFP_ - easier to ask forgiveness than permission - try catch, can not be ignored, _LBYL_ - look before you leap - if else without exception, error codes, silent,\n\n#### Iteration and Iterables\n\n_comprehensions_ - concise syntax to transform collections without side effects - consists of expression, for loop and optional predicate, _generator functions_ - iterables defined via functions, have yield keyword, evaluated lazily, can model infinite sequences, can maintain state in local variables, _iteration protocols_ - iter() and next(), _generator expressions_ - create generator objects  with comprehensions, use (...) braces, _itertools_ - module for working with iterators, \n\n#### Classes\n\n_classes_ - custom types, classes are callable objects in Python, name bound to definition once at runtime, PascalCase naming, no new keyword, _self_ - equivalent to this in Java, simply assign class attributes without declaration, _\\_\\_init\\_\\_()_ - initializer, not a constructor, for configuring already created object, _methods_ - first argument is self and passed explicitly, _no access modifiers_ - everything is public, underscore for private attributes, _invariants_ - constraints, validate attributes, _duck typing_ - argument fitness determined at runtime, not by inheritance hierarchy at compile time, _late binding_ - use object to resolve method calling at runtime, _polymorphism_ - through late binding, not through inheritance, _inheritance_ - used only for reusing implementation, \n\n#### File IO and Resource Managements\n\n_files and file like objects_ - text and binary mode, support iterator and context manager protocols, _universal newline_ - OS independent, _bitwise operators_, _with block_ - syntactic sugar for try except structure for managing resources using objects that implement context manager protocol, \n\n---\n\n### Beyond the Basics\n\n#### Organizing Larger Programs\n\n_packages_ - folders, _modules_ - files, _sys.path_ - list of all included directories with modules, _PYTHONPATH_ - OS level environment variable that is included in sys.path, _\\_\\_init\\_\\_.py_ - index file that creates  a package from a folder, _subpackages_ - package can have hierarchy, _relative imports_ - from import syntax with a dot, _\\_\\_all\\_\\__ - export only some variables from a module, _namespace packages_ - package composed from a few sibling folders, _\\_\\_main\\_\\_.py_ - create executable directories, _recommended layout_ - recommended folder structure with source, test, index and setup files, _module singletons_ - variables defined in modules are singletons, \n\n#### Beyond Basic Functions\n\n_positional and keyword arguments_ - determined in the function call, _default arguments_ - evaluated only once at import time, must not be mutable value, _callable instances_ - their class has \\_\\_call\\_\\_() method defined, used as stateful functions, _callables_ - functions, classes, callable objects, lambdas, _conditional expressions_ - ternary expression equivalent, _lambdas_ - single expression anonymous functions, _extended formal and actual arguments syntax_ - def fn(\\*args, \\*\\*kwargs), fn(\\*args), fn(\\*\\*args) - equivalent to rest and spread syntax in JavaScript, unpacking - destructuring, _global functions_ - definition bound to name at runtime (import time), _local functions_ - redefined on each parent function call, _LEGB scopes_ - local, enclosing, global (module), built in, _function are first class citizens_ - can be passed, returned, assigned, _closures_ - maintain references from parent scopes, prevent garbage collection,\n\n#### Closures and Decorators\n\n_\\_\\_closure\\_\\__ - reference to the closure variables, _function factories_ - functions that returns new specialized functions, _nonlocal and global keywords_ - reuse variables frm parent and global scope, _decorators_ - syntactic sugar for higher oder functions, accepts callable and returns callable, can be nested, _@functools.wraps()_ - helper decorator for forwarding metadata of the decorated function, _instance attributes_ - per instance, \n\n#### Properties and Class Methods\n\n_class attributes_ - per class, same for all instances, _@staticmethod_ - does not reference neither class nor self, _@classmethod_ - references only class, _@property_ - property getter, _@name.setter_ - property setter, \n\n#### Strings and Representations\n\n_str()_ - simple string representation, calls \\_\\_str\\_\\_(), meant for users, called on print(), _repr()_ - verbose string representation, calls \\_\\_repr\\_\\_(), required, meant for developers, _format()_ - calls \\_\\_format\\_\\_(), optional, _ascii(), ord(), chr()_ - helpers for escaping and translating ascii to unicode strings, \n\n#### Numeric and Scalar Types\n\n_int_ - unlimited precision signed integer, _float_ - 64 bits floating point, _Decimal_ - configurable finite precision decimal floating point, _Fraction_ - rational numbers, _complex()_ - complex numbers, _abs(), round()_ - built in math helpers, _bin(), oct(), hex(), int()_ - number base conversion helpers, _datetime module_ - time(), datetime(), timedelta(), timezone() for working with time, \n\n#### Iterables and Iteration\n\n_advanced comprehensions_ - multiple input sequences - nested loops, if clauses, in the result expression of a comprehension - multidimensional result, _map()_ - returns iterable, lazy, _filter()_ - accepts predicate, returns iterable, lazy, _reduce()_ - summation generalization, _iter(iterable)_ - requires \\_\\_iter\\_\\_(), iterable protocol, _next(iterator)_ - requires \\_\\_next\\_\\_() and \\_\\_iter\\_\\_(), iterator protocol, _\\_\\_getitem\\_\\_()_ - iterable protocol for subsequent indexes, _iter(callable, sentinel)_ - extended iter format, \n\n#### Inheritance and Subtype Polymorphism\n\n_single inheritance_, _multiple inheritance_, _isinstance() and issubclass()_ - helper methods, _method resolution order - MRO_ - search order of inheritance graph, Class.\\_\\_mro\\_\\_ and mro(), calculated by C3 algorithm, which base class method will be called, _super()_ - returns bound class or instance proxy object in class or instance methods, returns base class in single inheritance, _inheritance usage_ - not for type hierarchy but for reusing implementation, \n\n#### Implementing Collections\n\n_collection protocols_ - container, sized, iterable, sequence, set, string representation and value equality protocols, _collections.abc_ - module with base implementations for collection protocols, \n\n#### Exceptions and Errors\n\n_standard exception hierarchy_, _custom exceptions_ - should extend from Exception class, _implicit chaining exceptions_ - handling new exceptions in except block, \\_\\_context\\_\\_ attribute, _explicit chaining exceptions_ - raise new exceptions from except block, \\_\\_cause\\_\\_ attribute, _traceback objects_ - stack trace, print_tb() and format_tb() for printing, _asserts_ - check assumptions, raise AssertionError for False, useful for return values,\n\n#### Defining Context Managers\n\n_context manager_ - object used in with statement, used for unmanaged resources, _context manager protocol_ - \\_\\_enter\\_\\_(), \\_\\_exit\\_\\_() - setup, teardown methods, for creating custom context managers, _@contextlib.contextmanager_ - decorator for creating context managers, _multiple context managers_ - nested, \n\n#### Introspection\n\n_introspection_ - programs can inspect their own structure and state, types, objects, scopes, _easier to ask forgiveness than permission - EAFP_ - optimistic philosophy, preferred, _look before you leap - LBYL_ - pessimistic philosophy, _dir(), getattr(), hasattr(), callable()_ - introspecting objects, _globals(), locals()_ - introspecting scopes, _inspect module_ - standard library module for introspecting objects, \n\n---\n\n### Advanced Python\n\n#### Advanced Flow Control\n\n_while else, for else clauses_ - no-break exit from a loop, _try else clause_ - no exception block, _emulating switch statements_ - if, elif, elif, else or dictionary of functions,\n\n#### Byte-oriented Programming\n\n_bitwise operators_ - and, or, xor, not, left and right shift, _bin() and to_bytes()_ - convert integers to bits and bytes, _bytes type_ - immutable sequence of bytes, _bytearray type_ - mutable sequence of bytes, _reading C structures_, _memoryview, memory mapped files_ - copy free working with binary data, C buffer protocol,\n\n##### Only short explanations bellow.\n\n#### Object Internals and Custom Attributes\n\n_object internal representation as dictionary_ - attributes in obj.\\_\\_dict\\_\\_, methods in obj.\\_\\_class\\_\\_.\\_\\_dict\\_\\_, \n\n#### Descriptors\n\n_descriptors_ - property objects that implement descriptor protocol, getter and setter equivalent,\n\n#### Instance Creation\n\n_instance allocation and initialization_\n\n#### Metaclasses\n\n_metaclasses_ - convert class definition into a class object, customization of class creation, type of a class object, \n\n#### Class Decorators\n\n_class decorators_ - simpler and less powerful metaclasses alternative, \n\n#### Abstract Base Classes\n\n_abstract base classes_ - customizable with metamethods, _abc module_ - tools for ABCs, _@abstractmethod_ - prevent instantiation of incomplete subclasses, \n\n\n---\n\n### Managing Python Packages and Virtual Environments\n\n#### Managing Python Packages with pip\n\n_pip_ - manage packages,\n\n#### Setting up Your Project with Virtual Environments\n\n_virtualenv, venv_ - isolated, per project dependencies and runtime, \n\n#### Using virtualenvwrapper to Make Your Life Easier\n\nutility tool\n\n#### Choosing the Right Tools\n\n_pipenv, poetry_ - deterministic dependency management, \n\n---\n\n### Python Best Practices for Code Quality\n\n#### Following Python Style Guidelines: PEP8 and Pylint\n\n_pylint, black_ - PEP8 formatting and linting,\n\n#### Documenting Your Project\n\n_docstrigns_, _sphinx_ - .rst to html converter, _apidoc_ - docstrings to html, \n\n#### Improve Your Code with Type Checking\n\n_type hints_ - optional type information, _mypy_ - static type checking, \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemanjam%2Fpython-overview","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnemanjam%2Fpython-overview","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnemanjam%2Fpython-overview/lists"}