Nested function scope problem

Gerhard Fiedler gelists at gmail.com
Fri Aug 4 18:44:17 EDT 2006


On 2006-08-04 15:21:52, Dennis Lee Bieber wrote:

> On Fri, 4 Aug 2006 14:09:15 -0300, Gerhard Fiedler <gelists at gmail.com>
> declaimed the following in comp.lang.python:
> 
>> Python === C
>> Textual representation a === Address operator (&a)
>> id(a) === Dereference operator (*a)
>> 
>> I think I didn't quite translate what you meant, but you get the idea. I
>> don't think you can come up with a working analogy. The differences are
>> just too many -- if you consider the C language on the right side, not a
>> custom application you developed in C.
>>
> 	Closer would be (putting C constructs on left)
> 
> c	~=	id(c)	(address of the object identified by 'c')
> *c	~=	c	(dereference to manipulate the object itself)
> &c	~=	no Python equivalent for "the address of the name 'c'" 
> 
> 	C 'c' is a variable, one can take the address of the storage it
> uses, and manipulate the contents of that storage. One does not have
> that access with Python name bindings.

But this means that C variables are not analog to Python variables, C
dereferenced pointers are. (c is a C variable; *c is /not/ a C variable,
it's a dereferenced pointer.) This is what I've been trying to say for a
while now... :)

Gerhard




More information about the Python-list mailing list