What is the difference between these two class declarations? What does "object" do?
class className(object): pass class className: pass
Why do I get this error when I run the below code: "Takes no arguments (1 given)"
class Hobbs(): def represent(): print "Hobbs represent!" represent = classmethod(represent) Hobbs.represent()
Why does "Foo.class_foo()" give no error even though I did not pass an argument to the function.
class Foo(object): @staticmethod def static_foo(): print "static method" @classmethod def class_foo(cls): print "Class method. Automatically passed the class: %s" % cls Foo.static_foo() Foo.class_foo()
Why do I get this error when I run the below code?
class Foo(object): def static_foo(): print "static method" static_foo = staticmethod(static_foo) def class_foo(cls): print "Class method. Automatically passed the class: %s" % cls class_foo = classmethod(class_foo) Foo.static_foo() Foo.class_foo()
"TypeError: unbound method static_foo() must be called with Foo instance as first argument (got nothing instead)"