Re: interating over single element array

2007-06-09 Thread Basilisk96
Thank you both for clearing that up. -Basilisk96 -- http://mail.python.org/mailman/listinfo/python-list

Re: interating over single element array

2007-06-09 Thread Terry Reedy
"Basilisk96" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | "Terry Reedy" <[EMAIL PROTECTED]> wrote: | > Any what if 'filelist' is any iterable other than a string or list? Your | > code is broken, and unnecessarily so. So I would call the parameter | > 'files' and test for isins

Re: interating over single element array

2007-06-09 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, Basilisk96 wrote: > "Terry Reedy" <[EMAIL PROTECTED]> wrote: >> Any what if 'filelist' is any iterable other than a string or list? Your >> code is broken, and unnecessarily so. So I would call the parameter >> 'files' and test for isinstance(files, str) #or basestring.

Re: interating over single element array

2007-06-09 Thread Basilisk96
"Terry Reedy" <[EMAIL PROTECTED]> wrote: > Any what if 'filelist' is any iterable other than a string or list? Your > code is broken, and unnecessarily so. So I would call the parameter > 'files' and test for isinstance(files, str) #or basestring. And wrap if it > is. Can you give an example of

Re: interating over single element array

2007-06-09 Thread Terry Reedy
"Basilisk96" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] | On Jun 8, 11:54 am, "T. Crane" <[EMAIL PROTECTED]> wrote: | You can also do this (if tuples are okay in your case): | | a = 1, | | The comma turns 'a' into a tuple (1,) which is both iterable and has a | length of 1. | | I

Re: interating over single element array

2007-06-08 Thread Basilisk96
On Jun 8, 11:54 am, "T. Crane" <[EMAIL PROTECTED]> wrote: > >> any suggestions are appreciated, > > > Yes, don't try iterating over objects that are not iterable. ;-) > > Ah, yes... I hadn't thought of that :) > > thanks, > trevis > > > > > What you *can* do is iterating over lists, tuples or othe

Re: interating over single element array

2007-06-08 Thread T. Crane
> >> any suggestions are appreciated, > > Yes, don't try iterating over objects that are not iterable. ;-) Ah, yes... I hadn't thought of that :) thanks, trevis > > What you *can* do is iterating over lists, tuples or other iterables with > just one element in them. Try ``a = [1]``. > > Ciao,

Re: interating over single element array

2007-06-08 Thread Marc 'BlackJack' Rintsch
In <[EMAIL PROTECTED]>, T. Crane wrote: > Can someone please explain to me why I can't do something like this: > > a = 1 > > for value in a: > print str(value) > > If I run this I get the error: > > 'int' object is not iterable Well the message explains why you can't do this. `a` is boun

interating over single element array

2007-06-08 Thread T. Crane
Hi all, Can someone please explain to me why I can't do something like this: a = 1 for value in a: print str(value) If I run this I get the error: 'int' object is not iterable Obivously this is an absurd example that I would never do, but in my application the length of 'a' can be anythi