With or Using

Nils Hensel nils.hensel at online.de
Tue Apr 17 18:30:04 EDT 2001


If you write:

 a = A()
 with a:
    .b = c

you could tell that b belongs to a while c is independant from a. This is
the only good way to use a with and also the only part I really like about
Visual Basic's syntax.

Nils



"Remco Gerlich" <scarblac at pino.selwerd.nl> schrieb im Newsbeitrag
news:slrn9dpdnf.amh.scarblac at pino.selwerd.nl...
> Tim Howarth <tim at worthy.demon.co.uk> wrote in comp.lang.python:
> > In message <3ADC5AE1.53C3C4FE at alcyone.com>
> >           Erik Max Francis <max at alcyone.com> wrote:
>  > > It saves a small amount of typing (and not very much) at the expense
of
> > > a lack of clarity and the addition of ambiguity.
> >
> > I thought with Python's block indenting it would be pretty clear what
> > was being referred to.
>
> Consider:
>
> a = A()
> with a:
>    b = c
>
> What does c refer to? Is it a.c or some global c? There's no way to tell.
> It might even change from time to time. I'm assuming that c would refer to
> a.c iff a has an attribute called c, and to another variable otherwise.
But
> even the fact that I have to make such an assumption shows that this
should
> not be Python... Be explicit as much as possible.
>
> --
> Remco Gerlich





More information about the Python-list mailing list