Module properties for C modules

Hello Python Dev! As you all know modules don't support properties. However several places and modules could use properties on module level. For example the sys.py3k_warnings flag could be implemented with a property. Other flags in the sys module could benefit from read only properties, too. How do you like the general idea of properties for builtin modules. That is modules written in C like the sys module. Christian

On Wed, Apr 30, 2008 at 4:17 PM, Christian Heimes <lists@cheimes.de> wrote:
Big +1. Frankly, the get/set methods of sys are quite ugly!
How do you like the general idea of properties for builtin modules. That is modules written in C like the sys module.
Good idea. Perhaps eventually they could be extended to Python, but they are definitely useful in C now. How about passing a list of getsets to PyImport_InitModule(5)?
-- Cheers, Benjamin Peterson

On Wed, Apr 30, 2008 at 2:17 PM, Christian Heimes <lists@cheimes.de> wrote:
But wouldn't this mean that those properties would no longer be available in the module's __dict__? -- --Guido van Rossum (home page: http://www.python.org/~guido/)

Guido van Rossum schrieb:
But wouldn't this mean that those properties would no longer be available in the module's __dict__?
Correct. Module properties would behave exactly like instance properties. They don't appear on the instance's __dict__ attribute, too. By the way I was astonished that the vars() function dones't show properties but dir() does list them.
Christian

On Thu, May 1, 2008 at 12:32 PM, Christian Heimes <lists@cheimes.de> wrote:
"Astonished" sounds stronger than you probably meant it. :-)
They are intentionally different though -- dir() tries to give all the attributes, while vars() only accesses __dict__. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Thu, May 1, 2008 at 1:20 PM, Christian Heimes <lists@cheimes.de> wrote:
What's your opinion on the module properties idea? Do you still like it although the property values won't show up in __dict__?
I don't see how it could work if any Python code is executed in the module, since code execution uses a dict for globals. Supporting it only for built-in modules seems too big an exception. So I'm -0. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Thu, May 1, 2008 at 2:00 PM, Christian Heimes <lists@cheimes.de> wrote:
Then I propose to drop the idea. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Wed, Apr 30, 2008 at 4:17 PM, Christian Heimes <lists@cheimes.de> wrote:
Big +1. Frankly, the get/set methods of sys are quite ugly!
How do you like the general idea of properties for builtin modules. That is modules written in C like the sys module.
Good idea. Perhaps eventually they could be extended to Python, but they are definitely useful in C now. How about passing a list of getsets to PyImport_InitModule(5)?
-- Cheers, Benjamin Peterson

On Wed, Apr 30, 2008 at 2:17 PM, Christian Heimes <lists@cheimes.de> wrote:
But wouldn't this mean that those properties would no longer be available in the module's __dict__? -- --Guido van Rossum (home page: http://www.python.org/~guido/)

Guido van Rossum schrieb:
But wouldn't this mean that those properties would no longer be available in the module's __dict__?
Correct. Module properties would behave exactly like instance properties. They don't appear on the instance's __dict__ attribute, too. By the way I was astonished that the vars() function dones't show properties but dir() does list them.
Christian

On Thu, May 1, 2008 at 12:32 PM, Christian Heimes <lists@cheimes.de> wrote:
"Astonished" sounds stronger than you probably meant it. :-)
They are intentionally different though -- dir() tries to give all the attributes, while vars() only accesses __dict__. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Thu, May 1, 2008 at 1:20 PM, Christian Heimes <lists@cheimes.de> wrote:
What's your opinion on the module properties idea? Do you still like it although the property values won't show up in __dict__?
I don't see how it could work if any Python code is executed in the module, since code execution uses a dict for globals. Supporting it only for built-in modules seems too big an exception. So I'm -0. -- --Guido van Rossum (home page: http://www.python.org/~guido/)

On Thu, May 1, 2008 at 2:00 PM, Christian Heimes <lists@cheimes.de> wrote:
Then I propose to drop the idea. -- --Guido van Rossum (home page: http://www.python.org/~guido/)
participants (3)
-
Benjamin Peterson
-
Christian Heimes
-
Guido van Rossum