Considering migrating to Python from Visual Basic 6 for engineering applications

Matt Wheeler m at
Fri Feb 19 12:05:48 EST 2016

On 19 February 2016 at 14:58, Peter Otten <__peter__ at> wrote:
> Tim Chase wrote:
>> [a long thing]
> Or just tell the parser what to expect:
> [another long thing]

If you're sure all of the words on a line are going to be numbers then

>>> [float(x) for x in '2 12.657823 0.1823467E-04 114 0'.split()]
[2.0, 12.657823, 1.823467e-05, 114.0, 0.0]

This will of course break if anything on the line *doesn't* look like
a float, but rather than jumping straight into a giant engineering
exercise I'd probably start there.

I'm sure there was a recent thread about returning the best fit type
(i.e. int, if not then float, if not then str)?

Matt Wheeler

More information about the Python-list mailing list