[Python-talk] Speaking of oops. How to call a method in another class in another file?
Larry Keber
lakkal at gmail.com
Tue Jul 28 14:49:30 EDT 2009
bruce.labitt at autoliv.com wrote:
> I'm plodding along with wxpython. I mostly have the graphic part set up.
> Now I am trying to connect the display to bits of my program. The first
> bit is to plot an existing data file. I used filepicker to get the full
> file name. I don't quite understand how to invoke/use one of the methods
> that I created in the class Xambig.
>
> Xambig is in the file genwave.py. Inside of Xambig is a method named
> plotMe.
>
(snip)
> if ( plot =="Plot existing"):
> p = genwave.Xambig()
> plotme(p, filepath, myrange) ???
>
>
The call would be:
p.plotme(filepath, myrange)
When you call it that way, the object itself ('p' in this case) is
implicitly passed as the first ('self') parameter of the method.
Larry
> Runtime error is NameError: global name 'plotme' is not defined. Looking
> for answers in the vast internet have not yielded too much. I hope this
> is simple. Rick Werme's example code is great, but I couldn't infer what
> to do from it. I learned a lot from doing this, but apparently not quite
> enough yet.
>
> Anyone got a suggestion? Besides "Step away from the terminal Sir"! This
> has been quite a good learning experience overall. I'm pleased with the
> overall project to date.
More information about the Python-talk
mailing list