-
-
Save public/5154306 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Printer(object): | |
def __call__(*args): | |
print 'call', args | |
def __get__(*args): | |
print 'get', args | |
return args[0] | |
def print_stuff(*args): | |
print(args) | |
class Bar(object): | |
def print1(*args): | |
print(args) | |
print2 = Printer() | |
print3 = print_stuff | |
Bar().print1() | |
Bar().print2() | |
Bar().print3() | |
""" | |
Prints: | |
(<__main__.Bar object at 0x10f3f6b10>,) | |
get (<__main__.Printer object at 0x10f3f6ad0>, <__main__.Bar object at 0x10f3f6b10>, <class '__main__.Bar'>) | |
call (<__main__.Printer object at 0x10f3f6ad0>,) | |
(<__main__.Bar object at 0x10f3f6b90>,) | |
""" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment