Python Object Errors
Posted:
Tuesday, July 10th, 2012Last modified:
Sunday, March 29th, 2015Overview
A collection of common errors experienced when working with Python objects.
Example Class
class Foo: def Bar(self): return 'Baz'
TypeError: unbound method Bar()
Incorrect syntax
print Foo.Bar() # OR # F = Foo print F.Bar()
Throws exception:
TypeError: unbound method Bar() must be called with Foo instance as first argument (got nothing instead)
Correct syntax
print Foo().Bar() # Prints "Baz" # OR # F = Foo() print F.Bar()
Available Wiki Topics
The operator of this site makes no claims, promises, or guarantees of the accuracy, completeness, originality, uniqueness, or even general adequacy of the contents herein and expressly disclaims liability for errors and omissions in the contents of this website.