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

Georgy Pruss see_signature__ at hotmail.com
Tue Nov 18 17:33:35 EST 2003


"Andrew Dalke" <adalke at mindspring.com> wrote in message news:J4tub.4889$sb4.2295 at newsread2.news.pas.earthlink.net...
| 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

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).

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

-- 
Georgy Pruss
E^mail: 'ZDAwMTEyMHQwMzMwQGhvdG1haWwuY29t\n'.decode('base64')






More information about the Python-list mailing list