@trainee wrote:
Hi
I have the following script :
class my(): def __init__(self): print('NOP') pass def __new__(cls): print('Init starts') cls.TEST = 'hey' print('Has been Init') m = my m() print(m) print(m, 'hey') print(my.TEST)
Which output the following lines :
NOP
__main__.my
(main.my at 0x0000000000000031>, 'hey')And then this :
Message: 'classobj' object has no attribute 'TEST'
Traceback:
line 15, in , "C:\Path\To\File.py"It just looks weird to me thqt the
__new__
function looks like it's never called.
What could i try ?Thank you in advance
Posts: 2
Participants: 1