On Mon, Jun 27, 2005 at 08:21:41AM -0600, John Roth wrote:
> Unfortunately, I've seen that behavior a number of times:
> no output is None, one output is the object, more than one
> is a list of objects. That forces you to have checks for None
> and list types all over the place.

maybe you can at least push this into a single convenience function...

def destupid(x, constructor=tuple, sequencetypes=(tuple, list)):
    if x is None: return constructor()
    if isinstance(x, sequencetypes): return x
    return constructor((x,))

Jeff

Attachment: pgpC9L79OCj2p.pgp
Description: PGP signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to