Calling a method from invoking module

Chris Rebert clp2 at rebertia.com
Fri Oct 29 06:06:22 CEST 2010


On Thu, Oct 28, 2010 at 8:33 PM, Baskaran Sankaran <baskarans at gmail.com> wrote:
> Sorry for the confusion; fooz(), track() and barz() are all members of their
> respective classes. I must have missed the self argument while creating the
> synthetic example.
>
> Yeah, I realize the mutual import is a bad idea. So, if I merge them into a
> single module (but still retaining the two classes) will work right? I
> guess, it will look like this after merging.
>
> Thanks again
> -b
>
> * foo_bar.py *
>
> class Foo:
>     def fooz(self):
>         print "Hello World"
>         b = Bar()
>         c = b.barz()
>         ...
>
>     def track(self, track_var):
>         count += 1

That line will raise UnboundLocalError. Where's count initialized?

>         return sth2
>
>
> class Bar:
>     def barz(self):
>         track_this = ...
>         if Foo.track(track_this):

You can't call an instance method on a class.

Cheers,
Chris
--
Nitpicker extraordinaire
http://blog.rebertia.com



More information about the Python-list mailing list