Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #20069

Read-only attribute in module

From Mateusz Loskot <mateusz@loskot.net>
Date 2012-02-09 11:43 +0000
Subject Read-only attribute in module
Newsgroups comp.lang.python
Message-ID <mailman.5583.1328787848.27778.python-list@python.org> (permalink)

Show all headers | View raw


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,
-- 
Mateusz Loskot, http://mateusz.loskot.net

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Read-only attribute in module Mateusz Loskot <mateusz@loskot.net> - 2012-02-09 11:43 +0000
  Re: Read-only attribute in module Ben Finney <ben+python@benfinney.id.au> - 2012-02-09 23:32 +1100
    Re: Read-only attribute in module mloskot <mateusz@loskot.net> - 2012-02-09 08:44 -0800
    Re: Read-only attribute in module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-10 01:04 +0000
      Re: Read-only attribute in module Terry Reedy <tjreedy@udel.edu> - 2012-02-09 22:27 -0500
        Re: Read-only attribute in module Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-02-10 22:23 +0000
      Re: Read-only attribute in module Arnaud Delobelle <arnodel@gmail.com> - 2012-02-10 10:09 +0000

csiph-web