Classification: UNCLASSIFIED
Caveat (s): FOUO
 
I have a program that collects weather data from weather models.  I originally had a module that contained a bunch of function that I used.  So I just added it to the init of the class I was using and inherited the functions.  That worked great but now I have two different models that I can get weather from.   Each Module A and B have the exact same function names in them but they both do slightly different things.
 
The idea is as I step through a list I want to use a different function (same name but from a different module) for each element in the list.  How do I have a generic way to do this.
 
for example for point 1 I want to use the rain function from Module A and then for point 2 I want to use the rain function from Module B.   At first though I would just init the class from either A or B for each point but I need the function from A or B to be able to use function from my main program...that is why the inheritance thing worked great for just one module. 
 
I have tried to make a very simple and not syntactically correct mockup of the code to help illustrate my problem.
 
class forecast:
       def __init__(self)
 
       def calcTime(self):
             #calculate some time and date stuff.
            x.day = time stuff
           x.time = time stuff
 
       def cloths2Wear(self):
              self.rain() # I wan to make this simple call but somewhere along the line have set which module
 
       def getPoint(self):
              self.pointList = 1,2,3,4,5,6
 
       def pointInfo(self):
             # get info about the point say which model to use
             x.model = A or B
 
x = forecast()
x.getPoint()
for each in x.pointList:
       x.pointInfo(each)
       x.rain() # I want to call the correct function based on what was set in pointInfo.
      
      
 
module A
 
class A:
     def __init__(self):
          self.model=A
 
     def rain(self):
           self.calTime() # this function is in the main forecast class
           self. rain = do stuff for model A
          
module B
 
class B:
     def __init__(self):
          self.model=B
 
     def rain(self):
           self.calTime() # this function is in the main forecast class
           self. rain = do stuff for model B
 
 
Thanks for any ideas you might have.
 
John Ertl
Meteorologist
 
FNMOC
7 Grace Hopper Ave.
Monterey, CA 93943
(831) 656-5704
[EMAIL PROTECTED]
 
Classification: UNCLASSIFIED
Caveat (s): FOUO
 
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to