return an object of a different class

spam at uce.gov spam at uce.gov
Wed Feb 16 00:17:13 EST 2011


I didn't explain my problem, chose a terrible example. This is more what I'm 
trying to do:

class thingy:
   def __init__(self, athingy):
     self.basic_extract()
     if self.typeof = A
              .../...

   def basic_extract(self):
     # complicated logic to extract data out of the thingy here
     # and set a bunch of values base on the data we extract
     self.size = xxx
     self.typeof = yyy
     self.weight = zzz

   def general_method(self)
     # Method that can be used on both types of thingy

class ThingyTypeA:
   def __init__(self):
     # do some further extraction specific to type A
     further_extract()


class ThingyTypeB:
   def __init__(self):
     # do some further extraction specific to type B
     further_extract()


-- 
Yves.                                                  http://www.SollerS.ca/
                                                        http://blog.zioup.org/



More information about the Python-list mailing list