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

Andrew Dalke adalke at mindspring.com
Tue Nov 18 12:58:01 EST 2003


Georgy Pruss:
> I guess, the same as for
>    hex(30+44j)
>    oct(3.1415926)
 ...

Which means you want
  str(obj) -> result as usual; takes any object, returns a string, all
numbers
    are represented in base 10
  str(obj, [base=10]) -> converts integer objects (only!) to the given base,
    defaults to base 10.

That feels wrong to me.  Base conversion is enough of a special
case that it doesn't warrant being part of the standard str constructor.
As an 'int.to_base' method or class method, perhaps, but not in str.

                    Andrew
                    dalke at dalkescientific.com






More information about the Python-list mailing list