Python scoping
Olivier Dagenais
olivierS.dagenaisP at canadaA.comM
Tue Oct 24 10:49:39 EDT 2000
I saw a half-funny article on how you can get Python to support explicit
scope start/end: just prefix your brace or keyword with the '#' character,
like so:
for c in range ( 100 ):
# do
print c,
# next c
...or if you come from a C background...
for c in range ( 100 ):
#{
print c,
#}
and Python is smart enough to match two different styles, too:
for c in range ( 100 ):
# do
print c,
#}
Note, however, you still need to properly indent your code...
--
----------------------------------------------------------------------
Olivier A. Dagenais - Software Architect and Developer
"Someone called 'Type your name here' is impersonating me on the
internet and is posting exactly the same things I am posting!"
"SuppamanX" <suppamanx at collector.org> wrote in message
news:8FD6F80F0suppamanxcollectoror at 209.155.56.95...
> 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. From a
> readability standpoint, it gets quite problematic for especially for some
> of the example code that I am trying to learn from.
>
> Can someone clarify why there is no explicit end for scopes?
> (i.e. IFs, FORs, WHILEs, METHODs, etc...)
>
> Thanx
More information about the Python-list
mailing list