Hasty Briefsbeta

Bilingual

Object Oriented Python

a day ago
  • Python's flexibility includes dynamic typing, array splicing, list concatenation with '+', and using docstrings as documentation.
  • Python forbids compile-time type declarations, global variable assignment in the same statement, and bad indentation.
  • Python objects use built-in functions like len() that call special methods (__len__), enabling uniform handling of different object types.
  • Inheritance is achieved by passing the superclass to the class definition; methods require explicit 'self' parameter for instance attribute access.
  • Constructors involve __new__ and __init__; destructors use __del__; the 'with' statement employs __enter__ and __exit__ instead.
  • Creating objects in Python is considered more complex than in other languages due to the need for special methods and understanding of garbage collection.