0

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 global_var
    global_var = 2

    def this_is_what_i_need():
        return global_var

print(Foo)

>>> 2

EDIT: After a comment from juanpa.arrivillaga I added global global_var

deepNdope
  • 179
  • 3
  • 14

0 Answers0