"a better input"
Alex Martelli
aleax at aleax.it
Thu May 9 02:12:48 EDT 2002
Alexis Layton wrote:
...
> What about allowing the following behavior for a "safe" input:
> read a line
> trim whitespace on both sides
No need to do that for the following step (only before you return the
string, if then).
> attempt to parse the string as a Python boolean, integer, real, or
> complex* literal
> otherwise return a the string
>
> *I realize there are no true complex literals, we'd have to do a little
> extra work here
What extra work?
>>> complex('23+45j')
(23+45j)
>>>
Alex
More information about the Python-list
mailing list