Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20100
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:module': 0.04; 'api.': 0.05; 'attribute': 0.07; 'python': 0.08; 'attributes,': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'recipe': 0.09; 'url:activestate': 0.09; 'martelli': 0.16; "wouldn't": 0.17; 'extension': 0.17; 'wrote:': 0.18; 'header:In-Reply-To:1': 0.22; 'module': 0.26; 'import': 0.27; 'url:code': 0.28; "i'm": 0.28; 'error': 0.30; 'alex': 0.31; 'implementing': 0.32; 'familiar': 0.32; 'implement': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'it.': 0.33; 'header:X-Complaints-To:1': 0.34; 'from:addr:yahoo.co.uk': 0.34; 'hi,': 0.34; 'to:addr:python-list': 0.35; 'received:org': 0.36; 'but': 0.37; 'using': 0.37; 'to:addr:python.org': 0.40; 'here': 0.64; 'due': 0.66; 'received:as13285.net': 0.84; 'received:2': 0.91; 'subject:Read': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| To | python-list@python.org |
| From | Mark Lawrence <breamoreboy@yahoo.co.uk> |
| Subject | Re: Read-only attribute in module |
| Date | Thu, 09 Feb 2012 19:35:13 +0000 |
| References | <CABUeae_vv=THd0VLsAteEKu7z8U2KA4p+vK1a=nAeMSKzM-L7g@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=ISO-8859-1; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Gmane-NNTP-Posting-Host | host-2-97-79-37.as13285.net |
| User-Agent | Mozilla/5.0 (Windows NT 6.0; rv:10.0) Gecko/20120129 Thunderbird/10.0 |
| In-Reply-To | <CABUeae_vv=THd0VLsAteEKu7z8U2KA4p+vK1a=nAeMSKzM-L7g@mail.gmail.com> |
| X-Antivirus | avast! (VPS 120209-2, 09/02/2012), Outbound message |
| X-Antivirus-Status | Clean |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.12 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.5607.1328816133.27778.python-list@python.org> (permalink) |
| Lines | 27 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1328816133 news.xs4all.nl 6887 [2001:888:2000:d::a6]:44459 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:20100 |
Show key headers only | View raw
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Read-only attribute in module Mark Lawrence <breamoreboy@yahoo.co.uk> - 2012-02-09 19:35 +0000
csiph-web