diff options
author | Jason Gerard DeRose <jderose@redhat.com> | 2008-12-31 15:47:28 -0700 |
---|---|---|
committer | Jason Gerard DeRose <jderose@redhat.com> | 2008-12-31 15:47:28 -0700 |
commit | b3063dbb8a652c9eb4eea940fff3032e2082dce3 (patch) | |
tree | bf47d4b2f39b195ee049bcdf3038cc35397c1103 /ipalib/base.py | |
parent | 86325bf4ebd8a9d40e81e4fd835635dfaa4139cd (diff) | |
download | freeipa-b3063dbb8a652c9eb4eea940fff3032e2082dce3.tar.gz freeipa-b3063dbb8a652c9eb4eea940fff3032e2082dce3.tar.xz freeipa-b3063dbb8a652c9eb4eea940fff3032e2082dce3.zip |
A few base.NameSpace docstring tweaks
Diffstat (limited to 'ipalib/base.py')
-rw-r--r-- | ipalib/base.py | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/ipalib/base.py b/ipalib/base.py index e3d08208c..6fcd248f2 100644 --- a/ipalib/base.py +++ b/ipalib/base.py @@ -18,7 +18,7 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -Low-level functions and abstract base classes. +Core functions and classes. """ import re @@ -255,6 +255,10 @@ class NameSpace(ReadOnly): >>> namespace = NameSpace([my_member]) >>> namespace NameSpace(<1 member>, sort=True) + + We can then access ``my_member`` both as an attribute and as a dictionary + item: + >>> my_member is namespace.my_name # As an attribute True >>> my_member is namespace['my_name'] # As dictionary item @@ -315,19 +319,19 @@ class NameSpace(ReadOnly): >>> list(ns()) # A more efficient, less verbose way to do it [Member(0), Member(1), Member(2)] - As another convenience, the `NameSpace.__todict__()` method will return copy - of the ``dict`` mapping the member names to the members. For example: + As another convenience, the `NameSpace.__todict__()` method will return a + copy of the ``dict`` mapping the member names to the members. For example: >>> ns.__todict__() {'member1': Member(1), 'member0': Member(0), 'member2': Member(2)} - - `NameSpace.__init__()` locks the instance, so `NameSpace` instances are - read-only from the get-go. For example: + As `NameSpace.__init__()` locks the instance, `NameSpace` instances are + read-only from the get-go. An ``AttributeError`` is raised if you try to + set *any* attribute on a `NameSpace` instance. For example: >>> ns.member3 = Member(3) # Lets add that missing 'member3' Traceback (most recent call last): - ... + ... AttributeError: locked: cannot set NameSpace.member3 to Member(3) (For information on the locking protocol, see the `ReadOnly` class, of which |