Comment on PEP-0238

James_Althoff at i2.com James_Althoff at i2.com
Mon Jul 9 21:06:51 CEST 2001


Tim Peters wrote:
<snip>
>The last time we solved a "it's *hard* to make sure temporary context
>changes get undone!" problem in Python was via adding ">>" to "print" <0.8
>wink>.  Python may want a more general approach to this kind of thing.

I'm hoping for the possibility of Python someday supporting "unnamed,
in-place (and fully functional)" code blocks as a possible "more general
approach" (a la Smalltalk and Ruby).

context.withPrecisionDo(max(8, oldp + 3)):
    do stuff
    return roundtoprecision(result, oldp)

lock.whileAcquiredDo():
    do stuff

mySideEffectObjectDo(args):
    do stuff

myFunkyCursor.showDuring():
    do stuff

myFile.whileOpenDo():
    do stuff

etc.

(Ignoring vexing details of syntax, semantics, etc. :-)

Jim





More information about the Python-list mailing list