[Python-ideas] Re: dict_items.__getitem__?

2021-10-07 Thread Stephen J. Turnbull
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

[Python-ideas] Re: String method to check for a float

2021-10-07 Thread Jeremiah Paige
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