Python scoping
jurgen.defurne at philips.com
jurgen.defurne at philips.com
Mon Oct 30 05:51:45 EST 2000
grante at visi.com@SMTP at python.org on 27/10/2000 19:00:03
Sent by: python-list-admin at python.org
To: python-list at python.org@SMTP
cc:
Subject: Re: Python scoping
Classification:
In article <8FD6F80F0suppamanxcollectoror at 209.155.56.95>, SuppamanX wrote:
> I have been using Python off and on for 6 months now and have grown to
>love it from the beginning. However, there is a facett of Python that
>annoys me somewhat. It is the 'scoping by indentation'. Coming from a
>background of 'formal' languages (e.g. Pascal, C, Java,...), I am
>accustomed to explicitly start and end my scopes with a braces.
Perhaps you already know this, and I'm about to sound overly
pedantic, but...
You're mixing together two different things: scoping and
statement grouping. They're two different (though in many
languages not orthogonal) things. In C, Pascal, Java, the
_same_ method is used for both scoping and grouping statements:
the begin/end tokens and curly-braces do two distinct things:
delimit a scope _and_ group multiple statements into a single
"statement".
In Python, indentation is used to group statements but it is
not used for scoping, as you seem to indicate.
>Can someone clarify why there is no explicit end for scopes?
>(i.e. IFs, FORs, WHILEs, METHODs, etc...)
In python, IF, FOR, WHILE do not start a new scope. The only
thing that starts a new scope is a function definition.
Or a class definition.
Jurgen
--
Grant Edwards grante Yow! BRILL CREAM is
at CREAM O' WHEAT in another
visi.com DIMENSION...
--
http://www.python.org/mailman/listinfo/python-list
More information about the Python-list
mailing list