Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- class X:
- def fn1(self):
- print("fn1")
- def fn2():
- print("fn2")
- def __init__(self):
- self.value = 99
- x = X() # OK
- x.fn1() # OK
- X.fn1(x) # OK
- #X.fn1() # TypeError: fn1() missing 1 required positional argument: 'self'
- #x.fn2() # TypeError: fn2() takes 0 positional arguments but 1 was given
- X.fn2() # OK in 3.2, 2.7: TypeError: unbound method fn2() must be called with X instance as first argument (got nothing instead)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement