Op 14-06-13 09:49, Nick the Gr33k schreef: > On 14/6/2013 10:36 πμ, Antoon Pardon wrote: >> Op 13-06-13 10:08, Νικόλαος Κούρας schreef: >>> >>> Indeed python embraced it in single quoting '0b100000001011010' and >>> not as 0b100000001011010 which in fact makes it a string. >>> >>> But since bin(16474) seems to create a string rather than an expected >>> number(at leat into my mind) then how do we get the binary >>> representation of the number 16474 as a number? >> >> You don't. You should remember that python (or any programming language) >> doesn't print numbers. It always prints string representations of >> numbers. It is just so that we are so used to the decimal representation >> that we think of that representation as being the number. >> >> Normally that is not a problem but it can cause confusion when you are >> working with mulitple representations. > Hold on! > Youa re basically saying here that: > > > >>> 16474 > 16474 > > is nto a number as we think but instead is string representation of a > number? Yes, or if you prefer what python prints is the decimal notation of the number.
> > I dont think so, if it were a string representation of a number that > would print the following: > > >>> 16474 > '16474' No it wouldn't, You are confusing representation in the everyday meaning with representation as python jargon. > Python prints numbers: No it doesn't, numbers are abstract concepts that can be represented in various notations, these notations are strings. Those notaional strings end up being printed. As I said before we are so used in using the decimal notation that we often use the notation and the number interchangebly without a problem. But when we are working with multiple notations that can become confusing and we should be careful to seperate numbers from their representaions/notations. > but when we need a decimal integer There are no decimal integers. There is only a decimal notation of the number. Decimal, octal etc are not characteristics of the numbers themselves. -- Antoon Pardon -- http://mail.python.org/mailman/listinfo/python-list