Too much builtins (was Re: Python's simplicity philosophy

Andrew Dalke adalke at mindspring.com
Tue Nov 18 18:04:42 EST 2003


Georgy Pruss:
> To me, it's very wrong that you can read any radix numbers, but can't
> print them. If str(int(s)) == s and int(str(n)) == n (with some limits), I
don't
> see why str(n,radix) can't be symmetrical to int(s,radix).

But your objection would also be handled with a special-case function
which only took an int/long and a base and returned the string
representation for that base, no?  This could be a method or a class
method of int, or a new function in math.  What makes it special enough
to warrant being part of the string constructor?

> BTW there's no symmetry for str() and list()/tuple()/dict() etc.

There is a symmetry for str(float(s)) == s and str(complex(s)) == s.
Why shouldn't those take a base?

Well, almost symmetry.  str(float("1.1")) != "1.1"

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list