[Python-Dev] str with base (original) (raw)
Andrew Bennetts andrew-pythondev at puzzling.org
Tue Jan 17 05:08:02 CET 2006
- Previous message: [Python-Dev] str with base
- Next message: [Python-Dev] str with base
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Mon, Jan 16, 2006 at 07:44:44PM -0800, Alex Martelli wrote:
Is it finally time in Python 2.5 to allow the "obvious" use of, say, str(5,2) to give '101',
My reaction having read this far was "huh?". It took some time (several seconds) before it occurred to me what you wanted str(5,2) to mean, and why it should give '101'.
If you'd proposed, say (5).as_binary() == '101', or "5".encode("base2"), I wouldn't have been as baffled. Or perhaps even str(5, base=2), but frankly the idea of the string type doing numeric base conversions seems weird to me, rather than symmetric.
I wouldn't mind seeing arbitrary base encoding of integers included somewhere, but as a method of str -- let alone the constructor! -- it feels quite wrong.
-Andrew.
- Previous message: [Python-Dev] str with base
- Next message: [Python-Dev] str with base
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]