Very practical question

Tim Roberts timr at probo.com
Thu Jul 6 02:21:32 EDT 2006


"madpython" <madpython at gmail.com> wrote:

>I've been doing an application with Tkinter widgets. Nothing really
>fancy just routine stuff. Though I have no problems with it by now I
>guess it would be reasonable to ask about a thing that's been bothering
>me a bit. Look at this piece of code:
>
>class A(object):
>    def a(self):
>        return "a from A"
>
>class B(object):
>    def interClassCall(self):
>        print globals()['c'].__dict__['a'].a()

The others have given you good advice about better ways to do this, but I'd
like to point out that this one line is equivalent to:

        print c.a.a()
-- 
- Tim Roberts, timr at probo.com
  Providenza & Boekelheide, Inc.



More information about the Python-list mailing list