0

Let say there is an external package which are can be invoke the following way

import GEOparse
gse = GEOparse.get_GEO(geo="GSE1563", destdir="./")

# I want to mypackage to inherit this iterator
for gsm_name, gsm in gse.gsms.iteritems():
   pass

Then I am making my own package which aim to wrap that external package and possibly later adding more functions.

mypackage.py

import GEOparse
def load(geoid=None, destdir=None, filepath=None):
   if filepath:
      GEOparse.get_GEO(filepath=filepath)
   else:
      GEOparse.get_GEO(geo=geoid, destdir=destdir)
   return

Now with this test code I'm calling mypackage without any problem

test_code.py

import mypackage
mygse = mypackage.load(filepath="./GSE74306.soft.gz")

My question is how can implement the iterator gse.gsm.iteritems inside mypackage. And how can I invoke that from test_code.py? I'm thinking to do something like:

for foo, bar in mygse.my_gsms_function.iteritems():
   pass
neversaint
  • 60,904
  • 137
  • 310
  • 477
  • I don't get your question. Are you asking how to implement an iterable object? – Bakuriu Nov 05 '15 at 07:35
  • @Bakuriu: Correct. *Implement iterable object that inherit from other package* to be specific. – neversaint Nov 05 '15 at 07:36
  • Then your question may be a duplicate of: http://stackoverflow.com/questions/9884132/what-exactly-are-pythons-iterator-iterable-and-iteration-protocols – Bakuriu Nov 05 '15 at 07:37
  • @Bakuriu: No. It doesn't tell you how to inherit from other package. – neversaint Nov 05 '15 at 07:38
  • 1
    Then your question is how to subclass? I believe you have to clarify exactly what you are trying to achieve and where is the problem; as it stands your question is quite broad. – Bakuriu Nov 05 '15 at 07:42

0 Answers0