Finn Mason writes:
> We don't need people writing `next(iter(iterable))` just to get the
> first item.
We already don't need that. `sequence[0]` and `next(iterator)` do the
trick.
You only need `next(iter(iterable))` if you need all three of
- an expression (`for first in iterable: break` gi
If the end goal is to just get either a float or an int from a string, and
you want to only accept floats the way Python spells them, what about using
ast.literal_eval?
>>> type(ast.literal_eval('1'))
>>> type(ast.literal_eval('1.0'))
>>> type(ast.literal_eval('01_105e-3'))
On Sun, Oct 3, 202