Python "with"

Bjoern Schliessmann usenet-mail-0306.20.chr0n0ss at spamgourmet.com
Sun Sep 16 17:34:50 EDT 2007


Ivan Voras wrote:
> I'm looking for a construct that's similar to (Turbo) Pascal's
> "with" statement. 

Please have a look at the archives -- this is discussed here from
time to time. I think last time it was a Visual BASIC fan that
asked a similar question.

> 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.)

Such big, javaish names are much uglier, IMHO.

Regards,


Björn

-- 
BOFH excuse #17:

fat electrons in the lines




More information about the Python-list mailing list