beginner, idiomatic python

bambam david at asdf.asdf
Fri Aug 24 00:50:00 EDT 2007


Thank you, so generallizing:

(1) Python re-evaluates the loop range on every loop, and
(2) Python does short-circuit evaluation of conditions, in predictable 
order.

Sorry about the bad question.


"Zentrader" <zentraders at gmail.com> wrote in message 
news:1187898049.734696.9500 at l22g2000prc.googlegroups.com...
> 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