New submission from HaiYun Yan lyricco...@gmail.com:
use as for block scope support
just like mozilla javascript let extension
https://developer.mozilla.org/en/new_in_javascript_1.7#Block_scope_with_let_%28Merge_into_let_Statement%29
usage:
as_clause(as_declare): as NAME
as_stmt: NAME as test
Ezio Melotti ezio.melo...@gmail.com added the comment:
You should propose this to the python-ideas mailing list first.
It might be worth checking the archives of the ML as well -- I think I saw
already something similar a while ago.
--
nosy: +ezio.melotti
resolution: - rejected
stage:
Paul Rubin a écrit :
[EMAIL PROTECTED] (Alex Martelli) writes:
locals['x']=5
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: 'builtin_function_or_method' object does not support item
assignment
Whoops, yeah, meant locals()['x'] = 5.
I think that ideally
Neal Becker [EMAIL PROTECTED] writes:
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also leads to
more readable code.
I have
On Apr 7, 4:48 am, James Stroud [EMAIL PROTECTED] wrote:
Neal Becker wrote:
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also
Alex Martelli schrieb:
Paul Rubin http://[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
exec?
option 1: that just runs the compiler a bit later ...
Besides exec, there's also locals(), i.e.
locals['x'] = 5
can shadow a variable. Any bad results are probably
.
I think Perl did this pretty good. If you say my $i that declares
$i to have block scope, and it's considered good practice to do this,
but it's not required. You can say for (my $i=0; $i 5; $i++) { ... }
and that gives $i the same scope as the for loop. Come to think of it
you can do
not. That works adequately.
I think Perl did this pretty good. If you say my $i that declares
$i to have block scope, and it's considered good practice to do this,
but it's not required. You can say for (my $i=0; $i 5; $i++) { ... }
and that gives $i the same scope as the for loop. Come
On Apr 7, 6:48 am, James Stroud [EMAIL PROTECTED] wrote:
Neal Becker wrote:
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also
Neal Becker [EMAIL PROTECTED] wrote:
...
i = 5
for my i in xrange(4):
if i: # skips first when i is 0
my i = 100
if i:
print i # of course 100
break
print i # i is between 0 3 here
print i # i is 5 here
Alex Martelli wrote:
Neal Becker [EMAIL PROTECTED] wrote:
...
i = 5
for my i in xrange(4):
if i: # skips first when i is 0
my i = 100
if i:
print i # of course 100
break
print i # i is between 0 3 here
print i # i
[EMAIL PROTECTED] (Alex Martelli) writes:
Thus the following example does not compile:
class Test {
public static void main(String[] args) {
int i;
for (int i = 0; i 10; i++)
I'm ok with this; at the minimum, I think such nesting should produce
a
Steve Holden [EMAIL PROTECTED] wrote:
What do you think the chances are of this being accepted for Python 3.0?
It is indeed about the most rational approach, though of course it does
cause problems with dynamic namespaces.
What problems do you have in mind? The compiler already determines
Paul Rubin http://[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
Thus the following example does not compile:
class Test {
public static void main(String[] args) {
int i;
for (int i = 0; i 10; i++)
I'm ok with this; at the
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
Steve Holden [EMAIL PROTECTED] wrote:
What do you think the chances are of this being accepted for Python 3.0?
It is indeed about the most rational approach, though of course it does
cause problems with dynamic namespaces.
.
I think Perl did this pretty good. If you say my $i that declares
$i to have block scope, and it's considered good practice to do this,
but it's not required. You can say for (my $i=0; $i 5; $i++) { ... }
and that gives $i the same scope as the for loop. Come to think of it
you can do
Aahz [EMAIL PROTECTED] wrote:
In article [EMAIL PROTECTED],
Alex Martelli [EMAIL PROTECTED] wrote:
Steve Holden [EMAIL PROTECTED] wrote:
What do you think the chances are of this being accepted for Python 3.0?
It is indeed about the most rational approach, though of course it does
[EMAIL PROTECTED] (Alex Martelli) writes:
exec?
option 1: that just runs the compiler a bit later ...
Besides exec, there's also locals(), i.e.
locals['x'] = 5
can shadow a variable. Any bad results are probably deserved ;)
--
http://mail.python.org/mailman/listinfo/python-list
and classes have a scope, but
if and for do not. That works adequately.
I think Perl did this pretty good. If you say my $i that declares
$i to have block scope, and it's considered good practice to do this,
but it's not required. You can say for (my $i=0; $i 5; $i++) { ... }
and that gives $i
Paul Rubin http://[EMAIL PROTECTED] wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
exec?
option 1: that just runs the compiler a bit later ...
Besides exec, there's also locals(), i.e.
locals['x'] = 5
can shadow a variable. Any bad results are probably deserved ;)
locals['x']=5
[EMAIL PROTECTED] (Alex Martelli) writes:
locals['x']=5
Traceback (most recent call last):
File stdin, line 1, in module
TypeError: 'builtin_function_or_method' object does not support item
assignment
Whoops, yeah, meant locals()['x'] = 5.
I think that ideally there should be a runtime
Paul Rubin wrote:
[EMAIL PROTECTED] (Alex Martelli) writes:
I have no opinion of this, locals() has always seemed like a crazy
part of the language to me and I never use it. I'd be happy to see it
gone since it makes compiling a lot easier.
I think of that, from a compiler perspective,
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also leads to
more readable code. I wonder if this has been discussed?
--
http
Neal Becker wrote:
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also leads to
more readable code. I wonder if this has been
On 4/6/07, Neal Becker [EMAIL PROTECTED] wrote:
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also leads to
more readable code. I
Neal Becker [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
| One thing I sometimes miss, which is common in some other languages
(c++),
| is idea of block scope. It would be useful to have variables that did
not
| outlive their block, primarily to avoid name clashes. This also
Neal Becker wrote:
One thing I sometimes miss, which is common in some other languages (c++),
is idea of block scope. It would be useful to have variables that did not
outlive their block, primarily to avoid name clashes. This also leads to
more readable code. I wonder if this has been
James Stroud [EMAIL PROTECTED] writes:
Probably, with good code, block scope would be overkill, except that I
would welcome list comprehensions to have a new scope:
Block scope is a win because it gets rid of the uncertainty of whether
the variable is used outside the block or not. The good
Paul Rubin wrote:
James Stroud [EMAIL PROTECTED] writes:
Probably, with good code, block scope would be overkill, except that I
would welcome list comprehensions to have a new scope:
Block scope is a win because it gets rid of the uncertainty of whether
the variable is used outside
this pretty good. If you say my $i that declares
$i to have block scope, and it's considered good practice to do this,
but it's not required. You can say for (my $i=0; $i 5; $i++) { ... }
and that gives $i the same scope as the for loop. Come to think of it
you can do something similar in C
30 matches
Mail list logo