@decorators

Bernhard Herzog bh at intevation.de
Sat Aug 7 12:42:46 EDT 2004


Tim Peters <tim.peters at gmail.com> writes:

> It does.  What it says is "arbitrary expressions will not work", and I
> would agree that's vague if you insisted it was <wink>.  What it means
> is that parameters are fine, but things like
>
> @list_of_decorators[index]

This could be written legally as
@list_of_decorators.__getitem__(1)

Or one could use operator.getitem

> @eatme and deco1 or deco2

@eval("eatme and deco1 or deco2")

> @random.choice([deco1, deco2, deco3])

That one is already legal!

Seems the restriction is somewhat pointless as it's easy to work around
if one really wants to.

  Bernhard

-- 
Intevation GmbH                                 http://intevation.de/
Skencil                                http://sketch.sourceforge.net/
Thuban                                  http://thuban.intevation.org/



More information about the Python-list mailing list