On May 7, 4:03 pm, Joel Bender <[EMAIL PROTECTED]> wrote:
> > Python 3.0 has such a formatting operation, but Python 2.x does not.
> > However it's not hard to write.
>
> Indeed. Refraining from using named lambdas:
>
> >>> def bin(x):
> ... return ''.join(x & (1 << i) and '1' or '
On Wed, 07 May 2008 13:13:40 -0700, dmitrey wrote:
> hi all,
> could you inform how to print binary number? I.e. something like
>
> print '%b' % my_number
>
> it would be nice would it print exactly 8 binary digits (0-1, with
> possible start from 0)
>
> Thank you in advance, D
Here it is:
de
Python 3.0 has such a formatting operation, but Python 2.x does not.
However it's not hard to write.
Indeed. Refraining from using named lambdas:
>>> def bin(x):
... return ''.join(x & (1 << i) and '1' or '0' for i in
... range(7,-1,-1))
...
>>> bin(12)
'00
On May 7, 3:31 pm, Mensanator <[EMAIL PROTECTED]> wrote:
> On May 7, 3:13 pm, dmitrey <[EMAIL PROTECTED]> wrote:
>
> > hi all,
> > could you inform how to print binary number?
> > I.e. something like
>
> > print '%b' % my_number
>
> > it would be nice would it print exactly 8 binary digits (0-1, wi
dmitrey wrote:
hi all,
could you inform how to print binary number?
I.e. something like
print '%b' % my_number
it would be nice would it print exactly 8 binary digits (0-1, with
possible start from 0)
Thank you in advance, D
--
http://mail.python.org/mailman/listinfo/python-list
Python 3.0
On May 7, 3:13 pm, dmitrey <[EMAIL PROTECTED]> wrote:
> hi all,
> could you inform how to print binary number?
> I.e. something like
>
> print '%b' % my_number
>
> it would be nice would it print exactly 8 binary digits (0-1, with
> possible start from 0)
>
> Thank you in advance, D
The gmpy works
hi all,
could you inform how to print binary number?
I.e. something like
print '%b' % my_number
it would be nice would it print exactly 8 binary digits (0-1, with
possible start from 0)
Thank you in advance, D
--
http://mail.python.org/mailman/listinfo/python-list