Did you know, that you can also define methods in Python this way?

def pr(*args):
print("i got %r" % args)

class Foo:
bar = pr

>>> Foo().bar()
i got <__main__.Foo object at 0x7f6b8b4ed950>

@Wolf480pl I used to monkey-patch classes this way.

def thing_that_wasnt_there(self):
# do something with the class

Class.new_thing = thing_that_wasnt_there

Follow

@Wolf480pl (But then I grow up and did things the proper way :D)

Sign in to participate in the conversation
Functional Café

functional.cafe is an instance for people interested in functional programming and languages.