Python 3.11.2 (tags/v3.11.2:878ead1, Feb 7 2023, 16:38:35) [MSC v.1934 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. DreamPie 1.2.1 >>> class MojeTřída: ... ... def fce(): ... print('MojeTřída.fce') ... ... a = 666 >>> MojeTřída 0: <class '__main__.MojeTřída'> >>> a Traceback (most recent call last): File "<pyshell#2>", line 1, in <module> a NameError: name 'a' is not defined >>> fce Traceback (most recent call last): File "<pyshell#3>", line 1, in <module> fce NameError: name 'fce' is not defined >>> MojeTřída.a 1: 666 >>> MojeTřída.fce 2: <function MojeTřída.fce at 0x0000017BADB2F740> >>> MojeTřída.fce() MojeTřída.fce >>> MojeTřída() 3: <__main__.MojeTřída object at 0x0000017BADB3E710> >>> mt = MojeTřída() >>> mt 4: <__main__.MojeTřída object at 0x0000017BADB3E8D0> >>> MojeTřída 5: <class '__main__.MojeTřída'> >>> dir(mt) 6: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'a', 'fce'] [About 28 more lines. Double-click to unfold] >>> mt.a 7: 666 >>> mt.fce() Traceback (most recent call last): File "<pyshell#13>", line 1, in <module> mt.fce() TypeError: MojeTřída.fce() takes 0 positional arguments but 1 was given >>> MojeTřída.fce() MojeTřída.fce >>> mt.fce() Traceback (most recent call last): File "<pyshell#15>", line 1, in <module> mt.fce() TypeError: MojeTřída.fce() takes 0 positional arguments but 1 was given >>> class MojeTřída: ... ... def __init__(self): ... print('Inicializace!') ... ... @staticmethod ... def fce(): ... print('MojeTřída.fce') ... ... a = 666 >>> MojeTřída.a 8: 666 >>> MojeTřída.fce 9: <function MojeTřída.fce at 0x0000017BADB2FB00> >>> MojeTřída.__init__ 10: <function MojeTřída.__init__ at 0x0000017BADB2FA60> >>> MojeTřída.fce() MojeTřída.fce >>> MojeTřída.__init__() Traceback (most recent call last): File "<pyshell#21>", line 1, in <module> MojeTřída.__init__() TypeError: MojeTřída.__init__() missing 1 required positional argument: 'self' >>> mt = MojeTřída() Inicializace! >>> mt.a 11: 666 >>> mt.fce 12: <function MojeTřída.fce at 0x0000017BADB2FB00> >>> mt.fce() MojeTřída.fce >>> mt.a 13: 666 >>> mt.a = 'xxx' >>> mt.a 14: 'xxx' >>> MojeTřída.a 15: 666 >>> def fn(): ... print('Ahoj!') >>> fn 16: <function fn at 0x0000017BADB2FE20> >>> fn() Ahoj! >>> fn.funkce = lambda: print('Baf!') >>> fn.funkce 17: <function <lambda> at 0x0000017BADB2FCE0> >>> fn.funkce() Baf! >>> class T: ... pass >>> mt 18: <__main__.MojeTřída object at 0x0000017BADB50FD0> >>> dir(mt) 19: ['__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getstate__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', 'a', 'fce'] [About 28 more lines. Double-click to unfold] >>> mt.b = 333 >>> mt.c = lambda: print('Haf!') >>> mt.c() Haf! >>> class MojeJináTřída(MojeTřída): ... b = 'Baf!' >>> mjt = MojeJináTřída() Inicializace! >>> mjt.a 20: 666 >>> mjt.b 21: 'Baf!' >>> mjt.fce() MojeTřída.fce >>> mt.b 22: 333 >>> type('abc') 23: <class 'str'> >>>