Package pycocoa :: Module internals :: Class proxy_RO
[frames] | no frames]

Class proxy_RO

object --+
         |
        proxy_RO
Known Subclasses:

Decorator for a lazy module dict or Read-Only module property.


See Also: Module Properties | the Proxy Pattern.

Instance Methods
 
__init__(self, func)
New proxy_RO.
 
__getattr__(self, name)
 
__getitem__(self, key)

Inherited from object: __delattr__, __format__, __getattribute__, __hash__, __new__, __reduce__, __reduce_ex__, __repr__, __setattr__, __sizeof__, __str__, __subclasshook__

Properties

Inherited from object: __class__

Method Details

__init__(self, func)
(Constructor)

 

New proxy_RO.

Parameters:
  • func - Function to be decorated as property (callable, invoked without args).
Overrides: object.__init__

Example:

>>> @proxy_RO
>>> def mattr():  # no args
>>>     return ro  # singleton
>>> x = [module.]mattr
>>> @proxy_RO
>>> def mdict():  # no args
>>>     d = dict(...)
>>>     return d # singleton
>>> x = [module.]mdict[k]