Re: eval('07') works, eval('08') fails, why?

2009-01-09 Thread Grant Edwards
On 2009-01-09, Dennis Lee Bieber wlfr...@ix.netcom.com wrote:
 On Thu, 08 Jan 2009 09:46:26 -0600, Grant Edwards inva...@invalid
 declaimed the following in comp.lang.python:


 Heathkit Z80 stuff used octal notation too.

   Octal worked well for the old 8080 and derivative processors as
 there were only 7 registers and memory/indirect to encode in an
 instruction... So (pseudo example) a MOV command might have been

   01sssddd (binary)

 or

   1SD (octal)


   and S or D representing

   A   1
   B   2
   C   3
   D   4
   E   5
   H   6
   L   7
   Mem 0   (indirect via contents of HL pair)

I presume that's why DEC chose octal for the PDP-11 also. There
were 8 registers and 8 addressing modes, so they ended up with
several fields within the opcodes that were three-bits wide and
aligned with octal digits:

  http://en.wikipedia.org/wiki/PDP-11#Instruction_set

When I was in University, we spent an entire quarter studying
the PDP-11 instruction set at the binary/octal level and
discussing instruction decoding and sequencing.  We wrote a few
PDP-11 assembly language programs as well, but the course was
more about machine level instruction sets than about assembly
language.

Octal made a lot of sense if you had to deal with raw memory,
but once you had access to an assembler and disassembler it
didn't really matter.

-- 
Grant Edwards   grante Yow! NANCY!!  Why is
  at   everything RED?!
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Thomas Guettler
Hi,

07 is octal. That's way 08 is invalid. Try this:

=== python
 print 011
9
 print int('011')
11




-- 
Thomas Guettler, http://www.thomas-guettler.de/
E-Mail: guettli (*) thomas-guettler + de
--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Mark Dickinson
On Jan 8, 9:31 am, Alex van der Spek am...@xs4all.nl wrote:

  eval('07')
 7
  eval('08')

 Traceback (most recent call last):
   File pyshell#3, line 1, in module
     eval('08')
   File string, line 1
     08
      ^
 SyntaxError: invalid token

An integer literal with a leading zero is
interpreted as an octal (base 8) number,
so only digits in the range 0-7 (inclusive)
are permitted in such a literal.

Mark



 I can't think of anything that could cause this. Similarly, eval('09')
 fails, but for string 0x with x8 it works. I am teaching myself Python
 in order to climb the ladder from 
 Algol(1980s)--Pascal(1990s)--VisualBasic(2000)--Python. I am a physicist, 
 have programmed computers

 all my life but I won't understand the real tech jargon of present day
 computer science. Please keep it simple

 Thanks in advance,
 Alex van der Spek

--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Grant Edwards
On 2009-01-08, Alex van der Spek am...@xs4all.nl wrote:

 Thanks much, that makes sense!

Well, that's the correct explanation.

Whether that feature makes sense or not is debatable.  Even I'm
not old-school enough that I ever use octal literals -- and I
used Unix on a PDP-11 for years (actually had my own PDP-11 for
while, but it never worked).  Now that I think of it, my
Heathkit Z80 stuff used octal notation too.

-- 
Grant Edwards   grante Yow! I represent a
  at   sardine!!
   visi.com
--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Alex van der Spek
Thanks much, that makes sense! Alex van der Spek

--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Ned Deily
In article hnwdnzhtdblpgvvunz2dnuvz_vzin...@posted.visi,
 Unknown unkn...@unknown.invalid wrote:
 On 2009-01-08, Alex van der Spek am...@xs4all.nl wrote:
  Thanks much, that makes sense!
 Well, that's the correct explanation.
 Whether that feature makes sense or not is debatable.

The debate is over!  In Py 3.0, octal literals changed from 07 to 0o7; 
the old format gets an 'invalid token' parsing error.

-- 
 Ned Deily,
 n...@acm.org

--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Terry Reedy

Alex van der Spek wrote:

I can't think of anything that could cause this. Similarly, eval('09') 
fails, but for string 0x with x8 it works. I am teaching myself Python 
in order to climb the ladder from Algol(1980s)--Pascal(1990s)--
VisualBasic(2000)--Python. I am a physicist, have programmed computers 
all my life but I won't understand the real tech jargon of present day 
computer science. Please keep it simple


I taught myself Python as a statistician with a Fortran/C backgound by 
interleaving interactive experiments (such as you did) with reading of 
the manuals.  The Language Manual chapter on Lexical Analysis has an 
Integer Literals subsection that answers this question.  I strongly 
recommend you peruse the Language Manual and the initial Library Manual 
chapters on built-ins.


tjr

--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Bruno Desthuilliers

Grant Edwards a écrit :

On 2009-01-08, Alex van der Spek am...@xs4all.nl wrote:


Thanks much, that makes sense!


Well, that's the correct explanation.

Whether that feature makes sense or not is debatable.  Even I'm
not old-school enough that I ever use octal literals -- and I
used Unix on a PDP-11 for years (actually had my own PDP-11 for
while, but it never worked).  Now that I think of it, my
Heathkit Z80 stuff used octal notation too.


What about your DeathStation 9000 ?-)
--
http://mail.python.org/mailman/listinfo/python-list


Re: eval('07') works, eval('08') fails, why?

2009-01-08 Thread Grant Edwards
On 2009-01-08, Bruno Desthuilliers bdesth.quelquech...@free.quelquepart.fr 
wrote:
 Grant Edwards a ?crit :
 On 2009-01-08, Alex van der Spek am...@xs4all.nl wrote:
 
 Thanks much, that makes sense!
 
 Well, that's the correct explanation.
 
 Whether that feature makes sense or not is debatable.  Even I'm
 not old-school enough that I ever use octal literals -- and I
 used Unix on a PDP-11 for years (actually had my own PDP-11 for
 while, but it never worked).  Now that I think of it, my
 Heathkit Z80 stuff used octal notation too.

 What about your DeathStation 9000 ?-)

The closest thing I've seen to a DS9K would probably be a CDC
Cyber 6600 mainframe.  I guess for somebody with a mainframe
background it might not have been too weird, but for somebody
who came from a PDP-11, Z80, 65XX background, it seemed awfully
obtuse.

-- 
Grant Edwards   grante Yow! I'm having a RELIGIOUS
  at   EXPERIENCE ... and I don't
   visi.comtake any DRUGS
--
http://mail.python.org/mailman/listinfo/python-list