ivoras at __fer.hr__
Sun Sep 16 22:07:07 CEST 2007
I'm looking for a construct that's similar to (Turbo) Pascal's "with"
statement. I read about the Python's new "with" statement, but I was
dissapointed to learn that it does something different (I still don't
see how it's better than try..except..finally, but that's not my question).
Is there something similar to what I want that's Pythonic enough?
(If you're not familiar with Pascal, here's how it works:
with some.big.structure.or.nested.objects.element do begin
member1 := something;
member2 := something;
which exactly translates to this equivalent:
some.big.structure.or.nested.objects.element.member1 := something;
some.big.structure.or.nested.objects.element.member2 := something;
i.e. it's a wrist-saver. I think a similar feature exists in C99, for
I know it can be almost always done by using a temporary variable:
tmp = some.big.structure.or.nested.objects.element
tmp.member1 = something
tmp.member2 = something
but this looks ugly to me.)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 258 bytes
Desc: OpenPGP digital signature
More information about the Python-list