[Python-Dev] PEP 340 keyword: after
Rodrigo Dias Arruda Senra
rodsenra at gpr.com.br
Thu May 5 15:23:39 CEST 2005
On Thu, 05 May 2005 14:58:02 +0200
"Martin v. Löwis" <martin at v.loewis.de> wrote:
> I haven't followed the PEP 340 discussion in detail,
> but as the PEP doesn't list keywords that have been
> considered and rejected, I'd like to propose my own:
> use "after" instead of "block":
>
> after opening("/etc/passwd") as f:
> for line in f:
> print line.rstrip()
>
> after locking(myLock):
> # code that needs to hold the lock
>
And *after* fits very nice for the examples above.
However, it might get weird for:
after transaction(db):
# code inbetween new_trasn/ commit_or_abort
The code pattern that will 'wrap' the block might
not always make sense with the chosen keyword, if
that keyword is not semantically neutral.
(not time-related, not function-related, etc).
Notice that is _no keyword_ is chosen, nothing prevents us
from using (even if by aliasing):
after_opening("/etc/passwd") as f:
for line in f:
print line.rstrip()
after_locking(myLock):
# code that needs to hold the lock
My two cents.
Senra
--
Rodrigo Senra
--
MSc Computer Engineer rodsenra(at)gpr.com.br
GPr Sistemas Ltda http://www.gpr.com.br/
Personal Blog http://rodsenra.blogspot.com/
More information about the Python-Dev
mailing list