Trees | Indices | Help |
|
---|
|
This modules provides the MinimalMatch class. Subclasses from this class have the special property that attribute names can be abbreviated:
>>> class MyClass(MinimalMatch): ... user = 'root' ... start = 'yesterday' ... stop = 'tomorrow' ... >>> my_instance = MyClass()
For instance the following command will set the 'user' attribute:
>>> my_instance.u = 'nobody' >>> print my_instance.user nobody
But of course you can always use the full attribute name:
>>> my_instance.user = 'root' >>> print my_instance.us root
Never type more than the full attribute name:
>>> print my_instance.users Traceback (most recent call last): ... AttributeError: MyClass instance has no attribute 'users'
Abbreviations should not be ambiguous:
>>> my_instance.st = 'now' Traceback (most recent call last): ... AttributeError: MyClass instance attribute 'st' is ambiguous
And setting instance attributes that are not class attributes is not possible:
>>> my_instance.group = 'nobody' Traceback (most recent call last): ... AttributeError: MyClass instance has no attribute 'group'
>>> print my_instance.stop tomorrow
Getting and setting private attributes should just work:
>>> my_instance._private = ('do', 'not', 'touch') >>> print my_instance._private ('do', 'not', 'touch')
And accesing non-existent private attributes should fail (and not land us in an infinite loop):
>>> print my_instance._does_not_exist Traceback (most recent call last): ... AttributeError: MyClass instance has no attribute '_does_not_exist'
|
|||
MinimalMatch Allow class attribute names to be abbreviated. |
Trees | Indices | Help |
|
---|
Generated by Epydoc 3.0.1 on Fri Nov 28 17:13:08 2008 | http://epydoc.sourceforge.net |