'with' statement in python ?
Alex Martelli
aleaxit at yahoo.com
Sat Jun 30 17:26:20 EDT 2001
"D-Man" <dsh8290 at rit.edu> wrote in message
news:mailman.993920867.31303.python-list at python.org...
> On Thu, Jun 28, 2001 at 10:13:40PM -0400, Steve Holden wrote:
> | The reappearance of the FAQ wizard allowed me to enter:
> |
> | 6.31. Why doesn't Python have a "with" statement like Delphi's Object
> | Pascal?
>
> I just found out that JavaScript has a "with" statement (spelled
> "with" too). Might want to add that.
Visual Basic (and VBA, and VBScript) have it, too. Again, same
spelling for the keyword, but attributes of the 'with-ed' object
are spelled with a leading dot. Nested with's are allowed, but
the outer one[s] are not "active" within an inner one -- e.g., in:
with fee
with fie
.foo = .fum(23)
end with
end with
both the .foo AND .fum references MUST be to attributes of
object fie -- there is NO role implicitly played by object fee
in this case.
Alex
More information about the Python-list
mailing list