Recursive Property of Octal Numbers

J

James Stroud

I'm very curious about what is going on here. I'm sure my curiosity has
something to do with ignorance of some fundamental concept of computer
science (maybe that 8 is just a vertical infinity?):

py> b = '\xb6'
py> b[0]
'\xb6'
py> b[0][0]
'\xb6'
py> b[0][0][0]
'\xb6'
py> b[0][0][0][0]
'\xb6'
py> b[0][0][0][0][0]
'\xb6'



James

--
James Stroud
UCLA-DOE Institute for Genomics and Proteomics
Box 951570
Los Angeles, CA 90095

http://www.jamesstroud.com/
 
P

PoD

I'm very curious about what is going on here. I'm sure my curiosity has
something to do with ignorance of some fundamental concept of computer
science (maybe that 8 is just a vertical infinity?):

py> b = '\xb6'
py> b[0]
'\xb6'
py> b[0][0]
'\xb6'
py> b[0][0][0]
'\xb6'
py> b[0][0][0][0]
'\xb6'
py> b[0][0][0][0][0]
'\xb6'



James

b is a 1 character string.
b[0] is a one character string which is the first character of b.
Therefore b[0] == b.
 
P

Paul Rubin

James Stroud said:
I'm very curious about what is going on here. I'm sure my curiosity has
something to do with ignorance of some fundamental concept of computer
science (maybe that 8 is just a vertical infinity?):

Python doesn't have a character type. A character is just a string of
length 1. So 'a'[0] is the same as 'a'. Thus 'a'[0][0][0]...[0] is
also the same as 'a'.
 
T

Tim Roberts

James Stroud said:
I'm very curious about what is going on here. I'm sure my curiosity has
something to do with ignorance of some fundamental concept of computer
science (maybe that 8 is just a vertical infinity?):

py> b = '\xb6'

8 doesn't have anything to do with it. What you have there is hexadecimal.
0377 is an example of an octal number.

However, as was pointed out elsewhere, the same thing would be true even if
you used 'z'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,045
Latest member
DRCM

Latest Threads

Top