[Python-talk] Speaking of oops. How to call a method in another class in another file?

bruce.labitt at autoliv.com bruce.labitt at autoliv.com
Tue Jul 28 16:32:53 EDT 2009


python-talk-bounces at dlslug.org wrote on 07/28/2009 04:12:19 PM:

> 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
> 

What if I don't want these defaults, but always want it passed from the 
outside?
If I comment out the initialization of myfile and myrange it dies.


> >         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
> > 
> 
> _______________________________________________
> 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>
******************************


More information about the Python-talk mailing list