[Python-3000] decorators for variable assignments?

Guido van Rossum guido at python.org
Fri Sep 21 19:40:55 CEST 2007


None of the arguments for function and class decorators apply here.

On 9/21/07, Arvind Singh <arvind1.singh at gmail.com> wrote:
> Hi,
>
> We have function and class decorators. Can we also have decorators for
> variable assignments?
>
> For example:
>   @validate_proxy
>   proxy = "http://user:passwd@host:port/"
>
> be a syntactical sugar for:
>   proxy = validate_proxy("http://user:passwd@host:port/")
>
>
> Python is often used as a configuration language (small utility
> scripts, Django, etc.) and it makes more sense to have the validation
> of a user supplied configuration value at the time of assignment
> rather than leaving the burden of validation on every piece of code
> that uses it. Although both approaches can be used for it, a user will
> be more hesitant to edit the string in the latter form (the former one
> is also more readable IMHO).
>
>
> Arvind
>
> PS: I hope it's not something too radical to talk so late about.
> _______________________________________________
> Python-3000 mailing list
> Python-3000 at python.org
> http://mail.python.org/mailman/listinfo/python-3000
> Unsubscribe: http://mail.python.org/mailman/options/python-3000/guido%40python.org
>


-- 
--Guido van Rossum (home page: http://www.python.org/~guido/)


More information about the Python-3000 mailing list