the.bay.news

How to refer to current class object

Discussions on Python.org
How to refer to current class object
Is there some way I can refer to the current class object from within itself before it’s definition is completed? I have found a number of times where it would be very useful to be able to reference the currently running code object, something like ‘self’ but obviously not that. See code below which fails because ‘myClass’ is not defined at the time it is referenced: class myClass(): Var1 = 0 @classmethod def func1(): print("In func1") myClass.Var1 += 1 myCl...

0 comments

Sign in to join the discussion — your thebay.events account works here.

No comments yet.