[DiscordArchive] !?
[DiscordArchive] !?
'Archived author: Skarn • Posted: 2018-06-03T20:35:18.266000+00:00
Original source
```py
class SomeClass:
var = 'I need help with fixed_point
'
@classmethod
def something(cls):
print(cls.var)
if __name__ == '__main__':
SomeClass.something()
```4
Archived author: Skarn • Posted: 2018-06-03T20:35:30.436000+00:00
Original source
The example of using a class without instantiation
Archived author: Kavligula • Posted: 2018-06-03T20:35:46.122000+00:00
Original source
It's instantiated behind the scenes and then deleted by the garbage collector later
Archived author: Kavligula • Posted: 2018-06-03T20:35:57.382000+00:00
Original source
The object is still created and used, it's just not shown to you that that's happening
Archived author: Skarn • Posted: 2018-06-03T20:36:01.692000+00:00
Original source
It is neither instantiated, nor deleted
Archived author: Skarn • Posted: 2018-06-03T20:36:14.872000+00:00
Original source
Classes are objects in python
Archived author: Skarn • Posted: 2018-06-03T20:36:21.847000+00:00
Original source
They are instances of their metaclass
Archived author: Skarn • Posted: 2018-06-03T20:37:10.288000+00:00
Original source
which is also an object which is either PyObject called 'type', the default metaclass or a custom user-defined metaclass which determine the way its classes are created.
Archived author: Kavligula • Posted: 2018-06-03T20:37:29.135000+00:00
Original source
So then the class is still technically instantiated, it's just done at runtime
Archived author: Kavligula • Posted: 2018-06-03T20:37:45.910000+00:00
Original source
Because it itself is just an object of an earlier class