Can string formatting be used to convert an integer to its binary form ?

Mirco Wahab wahab at chemie.uni-halle.de
Thu Sep 28 18:53:52 EDT 2006


Thus spoke Fredrik Lundh (on 2006-09-28 23:35):

> Mirco Wahab wrote:
> 
>> - why doesn't have Python such a simple and useful thing as to_binstr(...)
> 
> useful?  really?  for what?

I don't really know, but according to google,
people often ask exactly for that and there
is no reason at all why one shouldn't expect
to get a /bit string/ from "%b" %.

So if people think it's badly needed, how
couldn't it be *not* useful then? ;-)

It feels to me (as it does sometimes
when diving into Python, to be honest)
simply as a shortcoming, - and the ter-
nary operator included in 2.5 was
imho a huge step forward, next will
be mutable strings and arrays will be
'called arrays' somewhere ... ;-)

(maybe somebody reverses the -v/-V switch too, hey)

Regards

Mirco



More information about the Python-list mailing list