.. include:: global.rst ============================================= 10: Advanced Attributes ============================================= Summary ============ - Name mangling can provide a private attribute that is difficult to access accidentally - Using closure you can create a private variable - Properties have getter, setter and delete functions which are called when you try to work with the attribute - You can create a private property using the property object and closure - The property object has additional methods which allow it to be used as a decorator Program ============ .. literalinclude:: programs/chapterTen.py :language: python Program Output ================= .. code-block:: console ---- Name Mangling Example ---- Balance: 1500 Access via mangled name: 1500 ---- Closure Example ---- 1 2 3 ---- Property (Getter/Setter/Deleter) ---- Getting value... 25 Setting value... Getting value... 30 Deleting value... ---- Private Property with Closure ---- Bob 20 Updated age: 25 ---- Property Decorator Example ---- Area: 20 Setting area... New width after setting area: 10.0 Deleting dimensions...