[Python-Dev] 2.4a2, and @decorators

Mark Russell marktrussell at btopenworld.com
Tue Aug 3 13:06:54 CEST 2004


On Tue, 2004-08-03 at 05:17, James Y Knight wrote:
> Things someone might want to do, ordered roughly from most reasonable 
> to least reasonable ;)
> @foo().bar()
> @foo or bar
> @mydecorators['foo']
> @lambda f: foo(f) or bar(f)
> 
> Why disallow these forms? It seems quite difficult, especially, to 
> explain why the first one does not, or should not, work.

I don't think any of these seem that likely in practice, and if you do
want them, it is not hard to say:

	# Hopefully some comment here explaining the reason why you're
	# doing this.  And a more meaningful name than foo_or_bar!
	foo_or_bar = foo or bar

	@foo_or_bar
	def func(): pass

I would say leave it like this for now.  It is easy to relax the
restriction later if there's a demand.

Mark



More information about the Python-Dev mailing list