Python critique

Octavian Rasnita orasnita at gmail.com
Fri Dec 10 17:46:41 EST 2010


From: "John Nagle" <nagle at animats.com>
> On 12/10/2010 2:31 AM, kolo 32 wrote:
>> Hi, all,
>>
>> Python critique from strchr.com:
>>
>> http://www.strchr.com/python_critique
> 
>    I have criticisms of Python, but those aren't them.
> 
>    Probably the biggest practical problem with CPython is
> that C modules have to be closely matched to the version of
> CPython.  There's no well-defined API that doesn't change.
> This make life easier for Guido and tough on everybody else.
> That's the real cause of Python's "version hell".
> 
>    On the scope front, given the lack of declarations, Python
> has done reasonably well.  Scopes in Python aren't as narrow
> as one might like, but this isn't a major headache.

How narrow are the scopes in Python?
Is each block (each level of indentation) a scope?
If it is, then I think it is very enough because the other cases can be detected easier or it might not appear at all in a well-written program.
If it is not, then yes, it is a problem.

Can you please tell me how to write the following program in Python?

my $n = 1;

{
  my $n = 2;
  print "$n\n";
}

print "$n\n";

If this program if ran in Perl, it prints:
2
1

I have tried to write it, but I don't know how I can create that block because it tells that there is an unexpected indent.

Thanks.

Octavian




More information about the Python-list mailing list