[Python-ideas] a few decorator recipes

Benjamin Peterson benjamin at python.org
Sat Apr 30 21:17:58 CEST 2011


Mathias Panzenböck <grosser.meister.morti at ...> writes:
> 
> def annotations(**annots):
> 	def deco(obj):
> 		if hasattr(obj,'__annotations__'):
> 			obj.__annotations__.update(annots)
> 		else:
> 			obj.__annotations__ = annots
> 		return obj
> 	return deco

Why would you want to do that?

> 
> def setannot(obj, key, value):

I don't see the point.





More information about the Python-ideas mailing list