I would like to change the output when I call print()
on a class (not the instantiation of it!) in Python. I am aware of the __str(self)__
method for instances. I would like to know its "static" equivalent.
class Foo()
global_var = 2
# solution code here
print(Foo)
>>> 2
This answer is related but does not answer my question because I have a global variable in my class that should be the print output: How to create a custom string representation for a class object?
EDIT: After a comment I removed the global declaration of the variable and tried to make my problem clearer