How do you express binary literals in Python?

For reference— future Python possibilities: Starting with Python 2.6 you can express binary literals using the prefix 0b or 0B.

For reference—future Python possibilities: Starting with Python 2.6 you can express binary literals using the prefix 0b or 0B: >>> 0b101111 47 You can also use the new bin function to get the binary representation of a number: >>> bin(173) '0b10101101' Development version of the documentation: What's New in Python 2.6.

Print int('01010101111',2)687>>> print int('11111111',2)255 Another way. Edit: Apparently the only way. Since the other way doesn't actually work.

There is no way you can express binary literals (or rather integers as binary): here's a link to language reference on that matter.

As far as I can tell Python, up through 2.5, only supports hexadecimal & octal literals. I did find some discussions about adding binary to future versions but nothing definite.

I am pretty sure this is one of the things due to change in Python 3.0 with perhaps bin() to go with hex() and oct(). EDIT: lbrandy's answer is correct in all cases.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions