How to convert a list of strings to a tuple of floats?

Mike Kazantsev mk.fraggod at gmail.com
Mon May 18 09:29:18 EDT 2009


On Mon, 18 May 2009 00:51:43 -0700 (PDT)
"boblatest at googlemail.com" <boblatest at googlemail.com> wrote:

> this is the conversion I'm looking for:
> 
> ['1.1', '2.2', '3.3'] -> (1.1, 2.2, 3.3)

Since itertools are useful in nearly every module and probably are
imported already...

  import itertools as it
  ftuple = tuple(it.imap( float, line.split('; ') ))

-- 
Mike Kazantsev // fraggod.net
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 205 bytes
Desc: not available
URL: <http://mail.python.org/pipermail/python-list/attachments/20090518/b62ccd52/attachment.sig>


More information about the Python-list mailing list