Skip to content

Instantly share code, notes, and snippets.

@danielhfrank
Created January 30, 2013 23:13
Show Gist options
  • Save danielhfrank/4678236 to your computer and use it in GitHub Desktop.
Save danielhfrank/4678236 to your computer and use it in GitHub Desktop.
Methods not defined within class don't pass self as first arg
class X(object):
def __str__(self):
return 'x'
def my_print_arg(*args):
print args[0]
def print_arg(*args):
print args[0]
if __name__ == '__main__':
x = X()
x.y = print_arg
x.y('z') # prints 'z'
x.my_print_arg('z') # prints 'x'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment