Ka-Ping Yee wrote:
The programmer who writes the function used to introduce a block
can hardly be relied upon to explain the language semantics. We
don't expect the docstring of every class to repeat an explanation
of Python classes, for example. The language reference manual is
for that; it's a different level of documentation.
Would 'suite' work as the keyword?
Calling these things 'suite' statements would match the Python grammar, give an
obvious visual indicator through the use of a keyword, reduce any confusion
resulting from the differences between Python suites and Ruby blocks (since the
names would now be different), and avoid confusion due to the multiple meanings
of the word 'block'.
And really, what PEP 340 creates is the ability to have user-defined suites to
complement the standard control structures.
Anyway, here's the examples from the PEP using 'suite' as the keyword:
suite synchronized(myLock):
# Code here executes with myLock held. The lock is
# guaranteed to be released when the block is left (even
# if by an uncaught exception).
suite opening(/etc/passwd) as f:
for line in f:
print line.rstrip()
suite transactional(db):
# Perform database operation inside transaction
suite auto_retry(3, IOError):
f = urllib.urlopen(http://python.org/peps/pep-0340.html;)
print f.read()
suite synchronized_opening(/etc/passwd, myLock) as f:
for line in f:
print line.rstrip()
Cheers,
Nick.
--
Nick Coghlan | [EMAIL PROTECTED] | Brisbane, Australia
---
http://boredomandlaziness.skystorm.net
___
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe:
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com