[Python-Dev] PEP 340 keyword: after
Chris Ryland
cpr at emsoftware.com
Thu May 5 16:55:18 CEST 2005
Rodrigo Dias Arruda Senra <rodsenra <at> gpr.com.br> writes:
> 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
I hate to add to what could be an endless discussion, but... ;-)
In this case, "while" is the better time-related prefix, whether
keyword (hopeless, due to ages-old boolean-controlled loop association)
or function, since you want to imply that the code block is going
on *while* the lock is held or *while* the file is open (and you also
want to imply that afterwards, something else happens, i.e., cleanup).
while_locked(myLock):
# code that needs to hold the lock
--Chris Ryland, Em Software
More information about the Python-Dev
mailing list