[Python-ideas] descriptors outside of classes

Eric Snow ericsnowcurrently at gmail.com
Wed Mar 30 23:27:08 CEST 2011

I suppose that is more specific than the __import__ builtin.  Classes have
__build_class__.  Functions don't have an equivalent in the global builtins.

For imports you have to go through __import__.  So a __module_class__
would dictate which class for import to use.  By default it would be
types.ModuleType.  Makes sense.


p.s. a __build_function__ would be meaningful addition particularly if the
def-from syntax were feasible.  I'm just saying... :)

On Wed, Mar 30, 2011 at 3:13 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>wrote:

> Eric Snow wrote:
>> I was just thinking along those same lines.  Sounds like twisted already
>> does it.  Does it amount to using a custom __import__?
> I don't know what Twisted does, but I was thinking of
> an attribute called __moduleclass__ that works a bit
> like the old __metaclass__ attribute.
> Then you could do
> class __moduleclass__:
>   ... descriptor definitions go here ...
> --
> Greg
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20110330/2f498dae/attachment.html>

More information about the Python-ideas mailing list