To 'with' or not to 'with': how is the question ?
Daniel Dittmar
daniel at dittmar.net
Sat Sep 2 18:08:57 EDT 2000
> This seems a good idea in origin (from Pascal), exagerated so
> much that spoils any traces of programming.
It's acutally much better than the original Pascal
- there is only one with active (only the inner most) at any time, so
you know where to look
- the point clear 'points' you to the with, in Pascal, an identifier
could belong to the with or be a local variable
Smalltalk has something very similar:
Transcript
print: 'some string';
print: 'another string';
nl.
So '.goes_against_OO' is a bit off - but it makes always nice copy.
Which one looks the best:
def alternativeOne ():
sys.stdout.write (...)
sys.stdout.write (...)
sys.stdout.write (...)
def alternativeTwo ():
syswrite = sys.stdout.write
syswrite (...)
syswrite (...)
syswrite (...)
def alternativeThree ():
with sys.stdout:
.write (...)
.write (...)
.write (...)
Daniel
More information about the Python-list
mailing list