Re: Nested function scope problem



On Thu, 03 Aug 2006 17:27:26 -0300
Gerhard Fiedler <gelists@xxxxxxxxx> wrote:

#> But seriously, for my comment this seems off-topic.

Well, you wrote "but it's not really understandable with a C++ concept
of variable". It is perfectly understandable to me. That's all I said
(or, at least, all I wanted to say).

#> I did not say that you can't create Python behavior with C (of
#> course you can, you can do /everything/ in C :). You can build
#> constructs made up of C variables that simulate everything that any
#> Python construct does. That's not the point. The point is how the
#> simple, built-in language variable behaves.

I agree.

For me, Python variable behaves just like a C++ variable (a pointer,
sure, but that's minor point to me... YMMV).

#> > #> You also don't expect the "identity" of a and b to be the same
#> > #> after assigning one to the other.
#> >
#> > Don't I?
#>
#> I don't know. Try replacing your printf statements with something
#> like "printf("%x %i %i\n",&a,a,*a);" and watch the first column.
#> The address operator is probably for a C programmer the closest to
#> what the id() function is to a Python programmer.

I disagree. At least in my understanding, which, up to now, was
perfectly enough to explain everything about how Python variables
behave:

The address operator in C is what textual representation (i.e. what
you type, like "a") is in Python. Equivalent of id() is a dereference
operator.

Of course, there are probably other ways to look at this. But I still
do not see why people claim that there is a significant difference
between what variables are in Python and in C++.

--
Best wishes,
Slawomir Nowaczyk
( Slawomir.Nowaczyk@xxxxxxxxx )

If at first you don't succeed, redefine success.

.



Relevant Pages

  • Re: Explanation of Instance Variables in Python
    ... >>I am writing a chapter for teaching OOP in Python. ... attributes in general is critical to understanding its implementation of OOP. ... fish, not serving fish, though;-): ...
    (comp.lang.python)
  • Re: "Private" Member Variables
    ... I'm having trouble understanding to what extent I ... > should follow this policy in my Python code so I thought I'd ask the group. ... Holy cow, Scott! ... approach to information hiding isn't broken. ...
    (comp.lang.python)
  • Re: why cannot assign to function call
    ... without offering evidence. ... The Python model binds a name to a particular Python object, ... understanding requires understanding first what ... The abstraction, and the requirement to ...
    (comp.lang.python)
  • Re: why python is slower than java?
    ... > data in many cases and I seek your understanding. ... > Now I will say that Python is comparable to Java in terms of disk I/O. ... I do hope you will accept my apologies. ...
    (comp.lang.python)
  • Re: What value should be passed to make a function use the default argument value?
    ... if a Python programmer *writes* some code instead; ... For the developer to change the names of a and b in the above published ... published interface, he is responsible for documenting that they are ...
    (comp.lang.python)