Re: How can I test if an argument is a sequence or a scalar?

2006-01-11 Thread Fuzzyman
That's a neat little piece of code there. All the best, Fuzzyman http://www.voidspace.org.uk/python/index.shtml -- http://mail.python.org/mailman/listinfo/python-list

Re: How can I test if an argument is a sequence or a scalar?

2006-01-11 Thread Russell E. Owen
In article [EMAIL PROTECTED], [EMAIL PROTECTED] wrote: I want to be able to pass a sequence (tuple, or list) of objects to a function, or only one. It's easy enough to do: isinstance(var, (tuple, list)) But I would also like to accept generators. How can I do this? Anything else is assumed

How can I test if an argument is a sequence or a scalar?

2006-01-10 Thread sandravandale
I want to be able to pass a sequence (tuple, or list) of objects to a function, or only one. It's easy enough to do: isinstance(var, (tuple, list)) But I would also like to accept generators. How can I do this? Anything else is assumed to be a single value (my fault if I pass a dict or

Re: How can I test if an argument is a sequence or a scalar?

2006-01-10 Thread Jean-Paul Calderone
On 10 Jan 2006 15:18:22 -0800, [EMAIL PROTECTED] wrote: I want to be able to pass a sequence (tuple, or list) of objects to a function, or only one. Generally it's better to keep your API consistent. If you are going to take sequences, only take sequences. Don't try to make the interface more

Re: How can I test if an argument is a sequence or a scalar?

2006-01-10 Thread sandravandale
Hi Jean-Paul, Thank you for the advice, I appreciate it, my university training was next to useless so I learn how to write good programs by the advice of helpful people in online communities. I'm really thankfull when people take the time to tell me when I'm doing something wrong and show me a

Re: How can I test if an argument is a sequence or a scalar?

2006-01-10 Thread sandravandale
Hi Jean-Paul, Thank you for the advice, I appreciate it, my university training was next to useless so I learn how to write good programs by the advice of helpful people in online communities. I'm really thankfull when people take the time to tell me when I'm doing something wrong and show me a

Re: How can I test if an argument is a sequence or a scalar?

2006-01-10 Thread Michael Spencer
Jean-Paul Calderone wrote: On 10 Jan 2006 15:18:22 -0800, [EMAIL PROTECTED] wrote: I want to be able to pass a sequence (tuple, or list) of objects to a function, or only one. ... but in case you're curious, the easiest way to tell an iterable from a non-iterable is by trying to iterate