Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20100 > unrolled thread
| Started by | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| First post | 2012-02-09 19:35 +0000 |
| Last post | 2012-02-09 19:35 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: Read-only attribute in module Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-09 19:35 +0000
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
|---|---|
| Date | 2012-02-09 19:35 +0000 |
| Subject | Re: Read-only attribute in module |
| Message-ID | <mailman.5607.1328816133.27778.python-list@python.org> |
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 following > > import xyz > print(xyz.flag) # OK > xyz.flag = 0 # error due to no write access > > Best regards, There's a recipe by Alex Martelli here http://code.activestate.com/recipes/65207-constants-in-python/ but most people wouldn't bother with it. As others have said simply use THIS_IS_A_CONSTANT. -- Cheers. Mark Lawrence.
Back to top | Article view | comp.lang.python
csiph-web