beginner, idiomatic python

Zentrader zentraders at gmail.com
Thu Aug 23 15:40:49 EDT 2007


Does page count change? i.e. is it necessary to retrieve it in every
loop or
tempList = ['1','2','3','4','5','6','7','8']
sampleList=[]
page_count = self.parent.GetPageCount()
<snipped>
     for i in range(page_count):

Also, once pagefound is set to True, all pages following will not be
appended to sampleList because it is not initialized to False under
the "for i in range(self.parent.GetPageCount())" loop.

Finally, if I understand the logic and question correctly, you want
something like
tempList = ['1','2','3','4','5','6','7','8']
sampleList=[]
page_count = self.parent.GetPageCount()
for port in tempList:
    for i in range(page_count):
        page=self.parent.GetPage(i)
        if (hasattr(page, "port")) and (page.port != int(port)) :
            sampleList.append(port)

or perhaps (I'm not sure)
tempList = [1, 2, 3, 4, 5, 6, 7, 8]
sampleList=[]
page_count = self.parent.GetPageCount()
for i in range(page_count):
        page=self.parent.GetPage(i)
        if (hasattr(page, "port")) and (page.port not in tempList) :
            sampleList.append(port)
 HTH




More information about the Python-list mailing list