[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
Wed Jul 29 10:02:22 EDT 2009


kent3737 at gmail.com wrote on 07/28/2009 10:53:21 PM:

> On Tue, Jul 28, 2009 at 4:32 PM, <bruce.labitt at autoliv.com> wrote:
> >> > 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?
> 
> Then maybe you don't want a class at all. It sounds like plotMe()
> should just be a plain function, not a member function.
> 
> Python functions don't have to be in a class.
> 
> Kent

In some ways just using a function would be a lot easier for me.  (At 
least I understand that!) However, I want to understand when to use a 
simple function vs. a method.  What are the advantages and disadvantages 
of each?

As I am typing, I am attempting to understand 
http://docs.python.org/tutorial/classes.html.  I don't understand what is 
being said yet.  In a little while I think I'll be able to understand 
enough (I hope) to ask the question...

Gee, maybe I should go to the next PySIG.  This would be a lot easier to 
ask questions if I could show the code, get advice, wave my arms, etc. 
When is the next meeting? 

Actually, I can't wait that long.  I have to figure this out long before 
next meeting.  Guess the list will have to suffer a bit longer.  Hopefully 
I haven't made it to anyones personal blacklist, yet.

Thanks,
Bruce

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