On Thursday 2005-09-22 20:00, Josiah Carlson wrote:
[Alexander Myodov:]
But for the performance-oriented/human-friendliness factor, Python
is anyway not a rival to C and similar lowlevellers. C has
pseudo-namespaces, though.
C does not have pseudo-namespaces or variable encapsulation in
Andrew Koenig wrote:
Interestingly enough, not all C++ compilers (Microsoft) hid variables
created in for loops
(http://www.devx.com/cplus/10MinuteSolution/28908/0/page/2).
That's because the C++ spec changed during standardization, when the
standards committee realized the original idea was
Nick Coghlan wrote:
Python, however, uses a dynamic name binding system and scopes are expensive
because they require setting up all of the machinery to support nested
visibility.
Scopes within a function needn't be anywhere near as expensive
as scopes for nested functions are. The compiler
Hello,
Don't want to be importunate annoyingly asking the things probably
trivial for experienced community, but need to ask it anyway, after
spending about two hours trying to find well-camouflaged error caused
by it.
Why the variables defined inside for/while/if statements
(including
Alexander Myodov [EMAIL PROTECTED] wrote:
Hello,
Don't want to be importunate annoyingly asking the things probably
trivial for experienced community, but need to ask it anyway, after
spending about two hours trying to find well-camouflaged error caused
by it.
In the future you
Hello Josiah,
Why the variables defined inside for/while/if statements
(including loop variables for for) are visible outside this scope?
JC if and while statements don't define variables, so they can't expose
JC them later in the scope.
They don't. They just leak internal ones:
i = 0
while i
Alexander Myodov wrote:
Thus, your example falls to case 1: i variable is newly declared for
this loop. Well, we don't reuse old value of i to start the iteration
from a particular place, like below?
i = 5
for i in [3,4,5,6,7]:
print i,
More general, the variables could be assumed
Alexander Myodov [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
Why the variables defined inside for/while/if statements
(including loop variables for for) are visible outside this scope?
Questions about why Python is the way it is belong on comp.lang.python, the
general Python
Alexander Myodov [EMAIL PROTECTED] wrote:
[snip Alexander Myodov complaining about how Python works]
i = 0
while i != 1:
i += 1
j = 5
print j
Maybe you don't realize this, but C's while also 'leaks' internal
variables...
int i = 0, j;
while (i != 1) {
i++;
j = 5;
}
Hello Josiah,
i = 0
while i != 1:
i += 1
j = 5
print j
JC Maybe you don't realize this, but C's while also 'leaks' internal
JC variables...
JC int i = 0, j;
JC while (i != 1) {
JC i++;
JC j = 5;
JC }
JC printf(%i %i\n, i, j);
Yeah, it may *leak* it in your example. But the
Alexander Myodov [EMAIL PROTECTED] wrote:
for (int i = 0; i 10; i++) works fine nowadays.
JC I'm sorry, but you are wrong. The C99 spec states that you must define
JC the type of i before using it in the loop. Maybe you are thinking of
JC C++, which allows such things.
gcc -std=c99
Please end this thread. It belongs in c.l.py. Nothing's going to change.
--
--Guido van Rossum (home page: http://www.python.org/~guido/)
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
Josiah Carlson wrote:
As for list comprehensions, they were literally meant to be a
completely equivalent translation of a set of for loops.
I don't think that's quite true. I doubt whether anyone
really thought about the issue when LCs were first being
discussed. I didn't, but if I had, I
On 9/22/05, Greg Ewing [EMAIL PROTECTED] wrote:
Josiah Carlson wrote:
As for list comprehensions, they were literally meant to be a
completely equivalent translation of a set of for loops.
I don't think that's quite true. I doubt whether anyone
really thought about the issue when LCs were
14 matches
Mail list logo