Need suggestion to speed up code...

Fredrik Lundh fredrik at pythonware.com
Sat May 12 18:14:49 CEST 2001


Brad Bollenbach wrote:

> Is there a reason that noone mentioned the tuple function?
>
> >>> x = (1, "hey", "how's it goin, dude?")
> >>> y = tuple(x)
> >>> y[1]
> 'hey'
>
> That should do what you require.

doesn't quite work if the data is in a string, though:

>>> x = """(1, "hey", "how's it goin, dude?")"""
>>> y = tuple(x)
>>> y
('(', '1', ',', ' ', '"', 'h', 'e', 'y', '"', ',', ' ', '"', 'h', 'o', 'w', "'",
 's', ' ', 'i', 't', ' ', 'g', 'o', 'i', 'n', ',', ' ', 'd', 'u', 'd', 'e', '?',
 '"', ')')

Cheers /F





More information about the Python-list mailing list