Small changes to base.ReadOnly docstring

This commit is contained in:
Jason Gerard DeRose
2008-12-30 01:08:04 -07:00
parent 8decf4d8c3
commit 7012bed299

View File

@@ -47,8 +47,6 @@ class ReadOnly(object):
... pass ... pass
... ...
>>> p = Person() >>> p = Person()
>>> p.__islocked__() # Initially unlocked
False
>>> p.name = 'John Doe' >>> p.name = 'John Doe'
>>> p.phone = '123-456-7890' >>> p.phone = '123-456-7890'
>>> del p.phone >>> del p.phone
@@ -56,18 +54,16 @@ class ReadOnly(object):
But after an instance is locked, you cannot set its attributes: But after an instance is locked, you cannot set its attributes:
>>> p.__lock__() # This will lock the instance >>> p.__lock__() # This will lock the instance
>>> p.__islocked__()
True
>>> p.department = 'Engineering' >>> p.department = 'Engineering'
Traceback (most recent call last): Traceback (most recent call last):
... ...
AttributeError: locked: cannot set Person.department to 'Engineering' AttributeError: locked: cannot set Person.department to 'Engineering'
Nor can you deleted its attributes: Nor can you deleted its attributes:
>>> del p.name >>> del p.name
Traceback (most recent call last): Traceback (most recent call last):
... ...
AttributeError: locked: cannot delete Person.name AttributeError: locked: cannot delete Person.name
However, as noted at the start, there are still obscure ways in which However, as noted at the start, there are still obscure ways in which
@@ -82,7 +78,7 @@ class ReadOnly(object):
False False
But again, the point is that a programmer would never employ the above But again, the point is that a programmer would never employ the above
techniques as a mere accident. techniques accidentally.
""" """
__locked = False __locked = False
@@ -142,7 +138,7 @@ def check_name(name):
>>> check_name('MyName') >>> check_name('MyName')
Traceback (most recent call last): Traceback (most recent call last):
... ...
ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'MyName' ValueError: name must match '^[a-z][_a-z0-9]*[a-z0-9]$'; got 'MyName'
Also, this function will raise a ``TypeError`` if ``name`` is not an Also, this function will raise a ``TypeError`` if ``name`` is not an
@@ -150,7 +146,7 @@ def check_name(name):
>>> check_name(u'my_name') >>> check_name(u'my_name')
Traceback (most recent call last): Traceback (most recent call last):
... ...
TypeError: name: need a <type 'str'>; got u'my_name' (a <type 'unicode'>) TypeError: name: need a <type 'str'>; got u'my_name' (a <type 'unicode'>)
So that `check_name()` can be easily used within an assignment, ``name`` So that `check_name()` can be easily used within an assignment, ``name``