Implicit lists

Dale Strickland-Clark dale at riverhall.NOTHANKS.co.uk
Thu Jan 30 10:48:58 EST 2003


Peter Hansen <peter at engcorp.com> wrote:

>This is probably a better approach in several ways:
>
>def ensureList(thing):
>  try:
>    return list(thing)
>  except TypeError:
>    return [thing]
>
>
>-Peter

Except it doesn't work :-)

>>> list('abc')
['a', 'b', 'c']
>>> 
--
Dale Strickland-Clark
Riverhall Systems Ltd




More information about the Python-list mailing list