[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 16:12:19 EDT 2009
bruce.labitt at autoliv.com wrote:
> That was my first approach. I got the following error
> AttributeError: Xambig instance has no attribute 'plotme'
>
Python is case-sensitive, so that should have been "p.plotMe", sorry, i.e.:
p.plotMe( myfile, myrange )
> What do I need to do in the __init__ part of the class? Right now it is
> empty.
> Do I need to do something like
>
> class Xambig:
> def __init__(self):
> # initialization stuff here... then
> myfile = "ambig.dat"
> myrange = 200.00
> self.plotme = plotMe(myfile, myrange)
>
>
Yes, you could do that sort of initialization stuff in __init__, if you
wanted your object to default to having those values.
LArry
> def plotMe(self, fileName, myRange):
> """plot all kinds of stuff"""
>
> Then
>
> if ( plot=="Plot existing" ):
> p = genwave.Xambig()
> p.plotme( myfile, myrange )
>
>
> -Bruce
>
> <snip>
>
>
>
>> _______________________________________________
>> Python-talk mailing list
>> Python-talk at dlslug.org
>> http://dlslug.org/mailman/listinfo/python-talk
>>
>
>
> ******************************
> Neither the footer nor anything else in this E-mail is intended to or constitutes an <br>electronic signature and/or legally binding agreement in the absence of an <br>express statement or Autoliv policy and/or procedure to the contrary.<br>This E-mail and any attachments hereto are Autoliv property and may contain legally <br>privileged, confidential and/or proprietary information.<br>The recipient of this E-mail is prohibited from distributing, copying, forwarding or in any way <br>disseminating any material contained within this E-mail without prior written <br>permission from the author. If you receive this E-mail in error, please <br>immediately notify the author and delete this E-mail. Autoliv disclaims all <br>responsibility and liability for the consequences of any person who fails to <br>abide by the terms herein. <br>
> ******************************
> _______________________________________________
> Python-talk mailing list
> Python-talk at dlslug.org
> http://dlslug.org/mailman/listinfo/python-talk
>
More information about the Python-talk
mailing list