How to convert string to float in Python 1.2

Peter Abel p-abel at t-online.de
Sun Jan 19 09:21:55 EST 2003


"Bill Walker" <kwalker at earth1.net> wrote in message news:<3e29dba4_4 at corp.newsgroups.com>...
> I'm using Python 1.2 on a ZEOS notebook which runs MS DOS 5.0. Python 1.5 or
> higher will NOT install in DOS mode.
> 
> I have a string that I need to convert to a float.
> 
> f = float('1.234')
> 
> for example.  This works in Python 1.5 but does not work in Python 1.2. Nor
> is there a built-in function or a string module that will work (that I have
> found). Any tricks to doing this conversion in version 1.2, short of writing
> my on string to float module?
> 
> 
> 
> 
> 
> 
> -----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
> http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
> -----==  Over 80,000 Newsgroups - 16 Different Servers! =-----

Don't know Python 1.5, but eval could be a very old function.
If it exist in 1.5 you would succeed with
>>> f = '1.234'
>>> 
>>> eval(f)
1.234

Peter




More information about the Python-list mailing list