Skip to content
This repository has been archived by the owner on Jun 17, 2023. It is now read-only.

Commit

Permalink
Add aliasing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
hynek committed Aug 7, 2014
1 parent 2992293 commit 7f777eb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,20 @@ It allows for things like default values for certain attributes, making them opt
False
>>> obj6.b is obj7.b
False

And if you want your classes to have certain attributes private, ``characteristic`` will keep your kwargs clean if not told otherwise[]:

.. doctest::

>> @attributes([Attribute("private")])
.. class CWithPrivateAttribute(object):
.. pass
>> obj8 = CWithPrivateAttribute(private=42)
>> obj8._private
42
>> @attributes([Attribute("private", keep_underscores=False)])
.. class CWithPrivateAttributeNoAliasing(object):
.. pass
>> obj8 = CWithPrivateAttributeNoAliasing(_private=42)
>> obj8._private
42

0 comments on commit 7f777eb

Please sign in to comment.