Re: Read-only attribute in module

2012-02-13 Thread mloskot
ire module. > Terry, Thanks for your really helpful notes. Best regards, - -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4464760.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Read-only attribute in module

2012-02-10 Thread Terry Reedy
On 2/10/2012 6:11 AM, mloskot wrote: The intent of xyz.flag is that it is a value set by the module internally. xyz is a module wrapping a C library. The C library defines concept of a global flag set by the C functions at some events, so user can check value of this flag. I can provide access t

Re: Read-only attribute in module

2012-02-10 Thread Steven D'Aprano
On Thu, 09 Feb 2012 22:27:50 -0500, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once >> attributes. > > So propose that propery() work at m

Re: Read-only attribute in module

2012-02-10 Thread mloskot
ible to map C API semantics to Python concepts as 1:1. - -- Mateusz Loskot http://mateusz.loskot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4382967.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Read-only attribute in module

2012-02-10 Thread Arnaud Delobelle
On 10 February 2012 03:27, Terry Reedy wrote: > On 2/9/2012 8:04 PM, Steven D'Aprano wrote: > >> Python happily violates "consenting adults" all over the place. We have >> properties, which can easily create read-only and write-once attributes. > > > So propose that propery() work at module level,

Re: Read-only attribute in module

2012-02-09 Thread Terry Reedy
On 2/9/2012 8:04 PM, Steven D'Aprano wrote: Python happily violates "consenting adults" all over the place. We have properties, which can easily create read-only and write-once attributes. So propose that propery() work at module level, for module attributes, as well as for class attributes.

Re: Read-only attribute in module

2012-02-09 Thread Steven D'Aprano
On Thu, 09 Feb 2012 23:32:59 +1100, Ben Finney wrote: > Mateusz Loskot writes: > >> I'm wondering, is there any mean to implement attribute in module scope >> which is read-only? > > Python is designed by and for consenting adults. Rather than > restricting, instead use conventions to make your

Re: Read-only attribute in module

2012-02-09 Thread Mark Lawrence
On 09/02/2012 11:43, Mateusz Loskot wrote: Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? So, the follow

Re: Read-only attribute in module

2012-02-09 Thread Terry Reedy
On 2/9/2012 6:43 AM, Mateusz Loskot wrote: Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? Not that I kn

Re: Read-only attribute in module

2012-02-09 Thread mloskot
kot.net -- View this message in context: http://python.6.n6.nabble.com/Read-only-attribute-in-module-tp4378950p4380150.html Sent from the Python - python-list mailing list archive at Nabble.com. -- http://mail.python.org/mailman/listinfo/python-list

Re: Read-only attribute in module

2012-02-09 Thread Ben Finney
Mateusz Loskot writes: > I'm wondering, is there any mean to implement attribute in module > scope which is read-only? Python is designed by and for consenting adults. Rather than restricting, instead use conventions to make your intent clear to the user of your library. > So, the following > >

Read-only attribute in module

2012-02-09 Thread Mateusz Loskot
Hi, I'm implementing Python 3 extension using the Python C API. I am familiar with defining new types, implementing get/set for attributes, etc. I'm wondering, is there any mean to implement attribute in module scope which is read-only? So, the following import xyz print(xyz.flag) # OK xyz.fla