DustanGroups at gmail.com
Mon Sep 17 02:57:06 CEST 2007
On Sep 16, 3:07 pm, Ivan Voras <ivoras at __fer.hr__> wrote:
> 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.)
>>> import this # Note item #5
More information about the Python-list