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
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
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
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
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
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
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