[Python-3000] decorators for variable assignments? (original) (raw)
Arvind Singh arvind1.singh at gmail.com
Fri Sep 21 19:31:10 CEST 2007
- Previous message: [Python-3000] Py3k Trivia :-)
- Next message: [Python-3000] decorators for variable assignments?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: [Python-3000] Py3k Trivia :-)
- Next message: [Python-3000] decorators for variable assignments?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]