a beginner, beginners question
Tim Chase
python.list at tim.thechases.com
Wed Mar 19 06:57:04 EDT 2008
> class example:
> def __init__(self, foo, bar):
> self.foo = foo
> self.bar = bar
>
> def method(self):
> print "method ... :"
> print self.foo
> print self.bar
>
> if __name__ == "__main__":
> obj = example
This makes "obj" a synonym for "example". You want to
instantiate your "example" class with
obj = example("Some foo", "Some Bar")
> obj.foo = "var1"
> obj.bar = "var2"
which then makes these two lines either unneeded or an
overwriting of the initialization
> obj.method
and this returns a function, not the results of the function.
You need to call it
obj.method()
-tkc
More information about the Python-list
mailing list