Python 3.13.7 (tags/v3.13.7:bcee1c3, Aug 14 2025, 14:15:11) [MSC v.1944 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. DreamPie 1.2.1 >>> class C: ... ... def __getitem__(self, i): ... return i >>> c = C() >>> c 0: <__main__.C object at 0x0000018E8DC99A90> >>> c[0] 1: 0 >>> c['a'] 2: 'a' >>> c[('a', print)] 3: ('a', <built-in function print>) >>> c[:] 4: slice(None, None, None) >>> c[::-1] 5: slice(None, None, -1) >>> dir(666) 6: ['__abs__', '__add__', '__and__', '__bool__', '__ceil__', '__class__', '__delattr__', '__dir__', '__divmod__', '__doc__', '__eq__', '__float__', '__floor__', '__floordiv__', '__format__', '__ge__', '__getattribute__', '__getnewargs__', '__getstate__', '__gt__', '__hash__', '__index__', '__init__', '__init_subclass__', '__int__', '__invert__', '__le__', '__lshift__', '__lt__', '__mod__', '__mul__', '__ne__', '__neg__', '__new__', '__or__', '__pos__', '__pow__', '__radd__', '__rand__', '__rdivmod__', '__reduce__', '__reduce_ex__', '__repr__', '__rfloordiv__', '__rlshift__', '__rmod__', '__rmul__', '__ror__', '__round__', '__rpow__', '__rrshift__', '__rshift__', '__rsub__', '__rtruediv__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__sub__', '__subclasshook__', '__truediv__', '__trunc__', '__xor__', 'as_integer_ratio', 'bit_count', 'bit_length', 'conjugate', 'denominator', 'from_bytes', 'imag', 'is_integer', 'numerator', 'real', 'to_bytes'] [About 73 more lines. Double-click to unfold] >>> (666).__str__() 7: '666' >>> def fn(): ... pass >>> dir(fn) 8: ['__annotations__', '__builtins__', '__call__', '__class__', '__closure__', '__code__', '__defaults__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__getstate__', '__globals__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__kwdefaults__', '__le__', '__lt__', '__module__', '__name__', '__ne__', '__new__', '__qualname__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__type_params__'] [About 37 more lines. Double-click to unfold] >>> class Namespace: ... ... a = 333 ... ... def fn(): ... print('Ahoj!') ... ... def f(x, y): ... return x + y >>> Namespace 9: <class '__main__.Namespace'> >>> dir(Namespace) 10: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', 'a', 'f', 'fn'] >>> Namespace.a 11: 333 >>> Namespace.f 12: <function Namespace.f at 0x0000018E8DCE7060> >>> Namespace.f(1, 2) 13: 3 >>> Namespace.f('ab', 'c') 14: 'abc' >>> Namespace.fn() Ahoj! >>> Namespace() 15: <__main__.Namespace object at 0x0000018E8DC99BE0> >>> Namespace 16: <class '__main__.Namespace'> >>> ns = Namespace() >>> dir(ns) 17: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', 'a', 'f', 'fn'] >>> ns.a 18: 333 >>> ns.fn 19: <bound method Namespace.fn of <__main__.Namespace object at 0x0000018E8BA34A50>> >>> Namespace.fn 20: <function Namespace.fn at 0x0000018E8DCE71A0> >>> Namespace.fn() Ahoj! >>> ns.fn() Traceback (most recent call last): File "<pyshell#28>", line 1, in <module> ns.fn() ~~~~~^^ TypeError: Namespace.fn() takes 0 positional arguments but 1 was given >>> Namespace.f 21: <function Namespace.f at 0x0000018E8DCE7060> >>> ns.f 22: <bound method Namespace.f of <__main__.Namespace object at 0x0000018E8BA34A50>> >>> Namespace.f(1, 2) 23: 3 >>> ns.f(1, 2) Traceback (most recent call last): File "<pyshell#32>", line 1, in <module> ns.f(1, 2) ~~~~^^^^^^ TypeError: Namespace.f() takes 2 positional arguments but 3 were given >>> class Rodič: ... def __init__(self): ... print('Rodič!') ... ... class Potomek(Rodič): ... pass >>> Potomek() Rodič! 24: <__main__.Potomek object at 0x0000018E8DC99D30> >>> class Rodič: ... def __init__(self): ... print('Rodič!') ... ... class Potomek(Rodič): ... def __init__(self): ... print('Potomek!') >>> Potomek() Potomek! 25: <__main__.Potomek object at 0x0000018E8DC99E80> >>> class Rodič: ... def __init__(self): ... print('Rodič!') ... ... class Potomek(Rodič): ... def __init__(self): ... super().__init__(self) ... print('Potomek!') >>> Potomek() Traceback (most recent call last): File "<pyshell#38>", line 1, in <module> Potomek() ~~~~~~~^^ File "<pyshell#37>", line 7, in __init__ super().__init__(self) ~~~~~~~~~~~~~~~~^^^^^^ TypeError: Rodič.__init__() takes 1 positional argument but 2 were given >>> class Rodič: ... def __init__(self): ... print('Rodič!') ... ... class Potomek(Rodič): ... def __init__(self): ... super().__init__() ... print('Potomek!') >>> Potomek() Rodič! Potomek! 26: <__main__.Potomek object at 0x0000018E8DC9A270> >>> class C: ... a = 333 ... _b = 444 ... __c = 666 >>> dir(C) 27: ['_C__c', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', '_b', 'a'] >>> C.a 28: 333 >>> C._b 29: 444 >>> C._C__c 30: 666 >>> class C: ... ... a = 333 ... ... def __init__(self, x): ... self.b = x ... ... def baf(self): ... print('Baf!') >>> c = C(666) >>> C.__dict__ 31: mappingproxy({'__dict__': <attribute '__dict__' of 'C' objects>, '__doc__': None, '__firstlineno__': 1, '__init__': <function C.__init__ at 0x0000018E8DD04A40>, '__module__': '__main__', '__static_attributes__': ('b',), '__weakref__': <attribute '__weakref__' of 'C' objects>, 'a': 333, 'baf': <function C.baf at 0x0000018E8DD04AE0>}) >>> c.__dict__ 32: {'b': 666} >>> class Plocha: ... ... def __init__(self, barva=None): ... self._barva = barva ... ... def get_barvu(self): ... print("Vracím barvu.") ... return self._barva ... ... def set_barvu(self, val): ... print("Nastavuji barvu na:", val) ... self._barva = val ... ... barva = property(get_barvu, set_barvu) >>> p = Plocha() >>> p 33: <__main__.Plocha object at 0x0000018E8DC9A900> >>> p.barva Vracím barvu. Vracím barvu. >>> p.barva = 'black' Nastavuji barvu na: black >>> p.barva Vracím barvu. 34: 'black' >>> dir(p) 35: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', '_barva', 'barva', 'get_barvu', 'set_barvu'] >>> p.__dict__ 36: {'_barva': 'black'} >>> Plocha.__dict__ 37: mappingproxy({'__dict__': <attribute '__dict__' of 'Plocha' objects>, '__doc__': None, '__firstlineno__': 1, '__init__': <function Plocha.__init__ at 0x0000018E8DCE7B00>, '__module__': '__main__', '__static_attributes__': ('_barva',), '__weakref__': <attribute '__weakref__' of 'Plocha' objects>, 'barva': <property object at 0x0000018E8DD01AD0>, 'get_barvu': <function Plocha.get_barvu at 0x0000018E8DCE79C0>, 'set_barvu': <function Plocha.set_barvu at 0x0000018E8DCE7600>}) >>> Plocha.__dict__['barva'] 38: <property object at 0x0000018E8DD01AD0> >>> dir(Plocha.__dict__['barva']) 39: ['__class__', '__delattr__', '__delete__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__get__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__isabstractmethod__', '__le__', '__lt__', '__name__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__set__', '__set_name__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'deleter', 'fdel', 'fget', 'fset', 'getter', 'setter'] >>> class Plocha: ... ... def __init__(self, barva=None): ... self._barva = barva ... ... @property ... def barva(self): ... print("Vracím barvu.") ... return self._barva ... ... @barva.setter ... def barva(self, val): ... print("Nastavuji barvu na:", val) ... self._barva = val >>> p = Plocha() >>> dir(Plocha) 40: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', 'barva'] >>> dir(p) 41: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__firstlineno__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__static_attributes__', '__str__', '__subclasshook__', '__weakref__', '_barva', 'barva'] >>> class Pokus: ... def __new__(cls): ... print('__new__:', cls) ... def __init__(self): ... print('__init__:', self) >>> Pokus() __new__: <class '__main__.Pokus'> >>>