'with' statement in python ?
Gerhard Häring
gerhard.nospam at bigfoot.de
Mon Jun 25 17:02:00 EDT 2001
On Mon, 25 Jun 2001 20:33:11 +0200 (CEST), asgard <asgard at hellnet.cz> wrote:
>Hello,
>writing self before every object's method really drives me
>crazy. Shouldn't there be 'with' statement like in Pascal, ie.
>
>self.a=1
>self.b=2
>
>could be written as
>
>with self:
> a=1
> b=2
>
>? Of course it would work with other names too.
You can use any name instead of self, some people use simply "s", for example.
I prefer code where self is used, though.
If this were a problem for me, I'd write an editor macro and map it to alt-s or
something.
Gerhard
--
mail: gerhard <at> bigfoot <dot> de registered Linux user #64239
web: http://highqualdev.com public key at homepage
public key fingerprint: DEC1 1D02 5743 1159 CD20 A4B6 7B22 6575 86AB 43C0
reduce(lambda x,y:x+y,map(lambda x:chr(ord(x)^42),tuple('zS^BED\nX_FOY\x0b')))
More information about the Python-list
mailing list