[Python-ideas] Extend module objects to support properties

M.-A. Lemburg mal at egenix.com
Wed Jan 30 09:37:02 CET 2013


On 30.01.2013 02:06, Larry Hastings wrote:
> 
> 
> Properties are a wonderful facility.  But they only work on conventional objects.  Specifically,
> they *don't* work on module objects.  It would be nice to extend module objects so properties worked
> there too.
> 
> For example, Victor Stinner's currently proposed PEP 433 adds two new methods to the sys module:
> sys.getdefaultcloexc() and sys.setdefaultcloexc().  What are we, Java?  Surely this would be much
> nicer as a property, sys.defaultcloexc.

Would be nice, but I'm not sure how you'd implement this, since module
contents are accessed directly via the module dictionary, so the attribute
lookup hook to add the property magic is missing.

Overall, it would be great to have modules behave more like classes.
This idea has been floating around for years, but hasn't gone far due
to the above direct content dict access approach taken by the Python
code.

-- 
Marc-Andre Lemburg
eGenix.com

Professional Python Services directly from the Source  (#1, Jan 30 2013)
>>> Python Projects, Consulting and Support ...   http://www.egenix.com/
>>> mxODBC.Zope/Plone.Database.Adapter ...       http://zope.egenix.com/
>>> mxODBC, mxDateTime, mxTextTools ...        http://python.egenix.com/
________________________________________________________________________

::::: Try our mxODBC.Connect Python Database Interface for free ! ::::::

   eGenix.com Software, Skills and Services GmbH  Pastor-Loeh-Str.48
    D-40764 Langenfeld, Germany. CEO Dipl.-Math. Marc-Andre Lemburg
           Registered at Amtsgericht Duesseldorf: HRB 46611
               http://www.egenix.com/company/contact/



More information about the Python-ideas mailing list