[Python-Dev] str with base (original) (raw)
M.-A. Lemburg mal at egenix.com
Tue Jan 17 11:30:37 CET 2006
- Previous message: [Python-Dev] str with base
- Next message: [Python-Dev] str with base
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Alex Martelli 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;-).
Hmm, how about this:
str(obj, ifisunicode_decode_using_encoding='ascii', ifisinteger_use_base=10, ifisfile_open_and_read_it=False, isdecimal_use_precision=10, ismoney_use_currency='EUR', isdatetime_use_format='%c')
and so on ?!
Or even better:
str(obj, **kws) and then call obj.str(**kws) instead of just obj.str() ?!
Seriously, shouldn't these more specific "convert to a string" functions be left to specific object methods or helper functions ?
-- Marc-Andre Lemburg eGenix.com
Professional Python Services directly from the Source (#1, Jan 17 2006)
Python/Zope Consulting and Support ... http://www.egenix.com/ mxODBC.Zope.Database.Adapter ... http://zope.egenix.com/ mxODBC, mxDateTime, mxTextTools ... http://python.egenix.com/
::: Try mxODBC.Zope.DA for Windows,Linux,Solaris,FreeBSD for free ! ::::
- Previous message: [Python-Dev] str with base
- Next message: [Python-Dev] str with base
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]