473,408 Members | 2,832 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Recursive Property of Octal Numbers

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/
Oct 1 '05 #1
3 1118
PoD
On Fri, 30 Sep 2005 15:40:51 -0700, James Stroud wrote:
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.

Oct 1 '05 #2
James Stroud <js*****@mbi.ucla.edu> writes:
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'.
Oct 1 '05 #3
James Stroud <js*****@mbi.ucla.edu> wrote:

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'.
--
- Tim Roberts, ti**@probo.com
Providenza & Boekelheide, Inc.
Oct 4 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

20
by: Sean McIlroy | last post by:
I recently found out that unicode("\347", "iso-8859-1") is the lowercase c-with-cedilla, so I set out to round up the unicode numbers of the extra characters you need for French, and I found them...
7
by: Jon Slaughter | last post by:
#pragma once #include <vector> class empty_class { }; template <int _I, int _J, class _element, class _property> class RDES_T {
1
by: Jim | last post by:
I need to input a stream of data that is a string. In that string are some octal numbers. What happen, did you forget the ushort.Parse(string,...) that accepts octal numbers? You have decimal...
2
by: gjuro kladaric | last post by:
hi there, I am just learning about IFormattable, ICustomFormatter, IFormatProvider and the like... although being a bit tricky to understand, it becomes clear after some clicking and...
27
by: fuch6921 | last post by:
I want to read in an Octal number argument and have it stored as an octal number. For instance the user will type: ./a.out 777 and it will store the octal number 777. But it atoi does this as an...
9
by: Csaba Gabor | last post by:
Inside a function, I'd like to know the call stack. By this I mean that I'd like to know the function that called this one, that one's caller and so on. So I thought to do: <script...
15
by: jaks.maths | last post by:
How to convert negative integer to hexadecimal or octal number? Ex: -568 What is the equivalent hexadecimal and octal number??
25
by: notahipee | last post by:
I have been trying to cin an number from 0 to 9 with a leading 0. For example 00 or 07. I was using a switch case. switch (int) { case 01: break; case 02: break;..... My problem arises at 08...
6
KevinADC
by: KevinADC | last post by:
This snippet of code provides several examples of programming techniques that can be applied to most programs. using hashes to create unique results static variable recursive function...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.