Re: Newbie - How to iterate list or scalar ?

2006-08-10 Thread Bruno Desthuilliers
Delaney, Timothy (Tim) wrote: Bruno Desthuilliers wrote: What I wonder here is why __iter__ has been added to lists and tuples but not to strings (not that I'm complaining, it's just curiousity...) Because someone got around to doing it. Ok, so it's definitively a design decision, and

Re: Newbie - How to iterate list or scalar ?

2006-08-09 Thread Bruno Desthuilliers
Terry Reedy wrote: Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] FWIW, the iterator protocol appeared with Python 2.2. Before this version, the above solution was the only one that allowed iteration over a container type. Now if you wonder why string,

RE: Newbie - How to iterate list or scalar ?

2006-08-09 Thread Delaney, Timothy (Tim)
Bruno Desthuilliers wrote: What I wonder here is why __iter__ has been added to lists and tuples but not to strings (not that I'm complaining, it's just curiousity...) Because someone got around to doing it. Tim Delaney -- http://mail.python.org/mailman/listinfo/python-list

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Richard Brodie
Andy Dingley [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be a list of the same variables. The obvious question would be, is there a good reason why you don't change

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Diez B. Roggisch
Andy Dingley wrote: I seem to be writing the following fragment an awful lot, and I'm sure it's not the best and Pythonic way to do things. Any advice on better coding style? pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Bruno Desthuilliers
Andy Dingley wrote: I seem to be writing the following fragment an awful lot, and I'm sure it's not the best and Pythonic way to do things. Any advice on better coding style? pluginVersionNeeded is a parameter passed into a method and it can either be a simple scalar variable, or it can be

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Andy Dingley
Bruno Desthuilliers wrote: there's really no reason to assume it should be a list - any iterable could - and IMHO should - be accepted... expect of course for strings (royal PITA case, duh). 2/ test for pluginVersionsNeeded.__iter__ (an attribute of most iterables except strings...):

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Bruno Desthuilliers
Andy Dingley wrote: Bruno Desthuilliers wrote: there's really no reason to assume it should be a list - any iterable could - and IMHO should - be accepted... expect of course for strings (royal PITA case, duh). 2/ test for pluginVersionsNeeded.__iter__ (an attribute of most iterables

Re: Newbie - How to iterate list or scalar ?

2006-08-08 Thread Terry Reedy
Bruno Desthuilliers [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] FWIW, the iterator protocol appeared with Python 2.2. Before this version, the above solution was the only one that allowed iteration over a container type. Now if you wonder why string, unicode and buffer don't