[Python-ideas] descriptors outside of classes
fuzzyman at gmail.com
Wed Mar 30 19:42:40 CEST 2011
On 30 March 2011 17:07, Eric Snow <ericsnowcurrently at gmail.com> wrote:
> Yeah, I figured as much. I am sure there is some convoluted way to make it
> work, but it would not nearly be worth it for what we would get out of it.
Well, it's still a *nice idea* even if it's impractical. For example to
allow for deprecation warnings on module variables Twisted creates a
subclass of modules (I believe), so that accessing the variable raises the
In the standard library we are unable to apply deprecation warnings to
module variables because we don't have a mechanism like this.
All the best,
> On Tue, Mar 29, 2011 at 10:07 PM, Nick Coghlan <ncoghlan at gmail.com> wrote:
>> On Wed, Mar 30, 2011 at 3:59 AM, Eric Snow <ericsnowcurrently at gmail.com>
>> > Here's another outlandish idea. How about if descriptors could be used
>> > outside of classes. I.e. any global or local variable could be assigned
>> > descriptor object and the descriptor protocol would be respected for
>> > variable. This would be a pretty messy change, and I have no illusions
>> > the idea will go anywhere. However, would there be room for this in
>> Not really, because globals() both promises to return a normal
>> dictionary and to respect changes to the module globals made via that
>> All bets are off with locals(), but the globals() aspect already
>> spikes the idea, as it does many other ideas to do with speeding or
>> otherwise enhancing namespace lookups.
>> Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
> Python-ideas mailing list
> Python-ideas at python.org
May you do good and not evil
May you find forgiveness for yourself and forgive others
May you share freely, never taking more than you give.
-- the sqlite blessing http://www.sqlite.org/different.html
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas