[Python-Dev] str with base (original) (raw)

Jean-Paul Calderone exarkun at divmod.com
Tue Jan 17 05:16:37 CET 2006


On Mon, 16 Jan 2006 19:44:44 -0800, Alex Martelli <aleaxit at gmail.com> wrote:

Is it finally time in Python 2.5 to allow the "obvious" use of, say, str(5,2) to give '101', just the converse of the way int('101',1) gives 5? I'm not sure why str has never allowed this obvious use -- any bright beginner assumes it's there and it's awkward to explain why it's not!-). I'll be happy to propose a patch if the BDFL blesses this, but I don't even think it's worth a PEP... it's an inexplicable though long-standing omission (given the argumentative nature of this crowd I know I'll get pushback, but I still hope the BDFL can Pronounce about it anyway;-).

-1. Confusing and non-obvious. The functionality may be valuable but it is mis-placed as a feature of str() or a method of the str type. I work with a lot of Python beginners too, and while they occassionally ask for this functionality, I've never heard anyone wonder why str() didn't provide it or suggest that it should.

Jean-Paul



More information about the Python-Dev mailing list