Python internals question

P

Peter Anderson

Hi! I am slowly teaching myself Python. I was reading David Beazley's
excellent book "Python - Essential Reference"; in particular about
variables. Let me quote:

"Python is a dynamically typed language in which names can represent
values of different types during the execution of a program. In fact the
names used in the program are really just labels for various quantities
and objects. The assignment operator simply creates an association
between a name and a value. This is different from C, for example, in
which a name (variable) represents a fixed size and location in memory..."

As an old mainframe programmer, I understand the way C does things with
variable but this text got me wondering how Python handles this
"association" between variable name and value at the lower level. Is it
like a fifo list?

If there is any Python guru that can help I would be most interested in
your thoughts.

Regards,
Peter
--

Peter Anderson

There is nothing more difficult to take in hand, more perilous to
conduct, or more uncertain in its success, than to take the lead in the
introduction of a new order of things — Niccolo Machiavelli, /The
Prince/, ch. 6
 
H

Helmut Jarausch

Peter said:
Hi! I am slowly teaching myself Python. I was reading David Beazley's
excellent book "Python - Essential Reference"; in particular about
variables. Let me quote:

"Python is a dynamically typed language in which names can represent
values of different types during the execution of a program. In fact the
names used in the program are really just labels for various quantities
and objects. The assignment operator simply creates an association
between a name and a value. This is different from C, for example, in
which a name (variable) represents a fixed size and location in memory..."

As an old mainframe programmer, I understand the way C does things with
variable but this text got me wondering how Python handles this
"association" between variable name and value at the lower level. Is it
like a fifo list?

If there is any Python guru that can help I would be most interested in
your thoughts.

Please have a look at

http://effbot.org/zone/call-by-object.htm

and

http://rg03.wordpress.com/2007/04/21/semantics-of-python-variable-names-from-a-c-perspective/


--
Helmut Jarausch

Lehrstuhl fuer Numerische Mathematik
RWTH - Aachen University
D 52056 Aachen, Germany
 
M

Marc 'BlackJack' Rintsch

"Python is a dynamically typed language in which names can represent
values of different types during the execution of a program. In fact the
names used in the program are really just labels for various quantities
and objects. The assignment operator simply creates an association
between a name and a value. This is different from C, for example, in
which a name (variable) represents a fixed size and location in memory..."

As an old mainframe programmer, I understand the way C does things with
variable but this text got me wondering how Python handles this
"association" between variable name and value at the lower level. Is it
like a fifo list?

Why a fifo list? Names don't remember the values and types they are bound
to over time, there's just one binding at any time if a name exists.
Internally you can think of a pointer to a struct that represents the
object.

Ciao,
Marc 'BlackJack' Rintsch
 
P

Peter Anderson

Helmut said:

Helmut,

I found the second reference (the one above) very useful thank you.
Most other respondents to my original question did not seem to
understand what I was asking or didn't read the question and simply
proceeded to re-state what I had quoted from Beazley - well I understood
what he was saying, I simply wanted to find out how Python did it at a
lower level. Your reference answered the question ;-)

Thanks,
Peter
--
Peter Anderson

There is nothing more difficult to take in hand, more perilous to
conduct, or more uncertain in its success, than to take the lead in the
introduction of a new order of things -- Niccolo Machiavelli, The
Prince, ch. 6
 

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

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top