From 44082d46f32a16f634a92f41cf3235d81acc6089 Mon Sep 17 00:00:00 2001 From: Mark Pilgrim Date: Tue, 14 Jul 2009 00:43:51 -0400 Subject: [PATCH] expand and explain the instance/class attribute example --- iterators.html | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/iterators.html b/iterators.html index 81b762d..8ae17c1 100755 --- a/iterators.html +++ b/iterators.html @@ -267,22 +267,28 @@ rules = LazyRules() >>> import plural6 >>> r1 = plural6.LazyRules() >>> r2 = plural6.LazyRules() ->>> r1.rules_filename +>>> r1.rules_filename 'plural6-rules.txt' >>> r2.rules_filename 'plural6-rules.txt' ->>> r1.__class__.rules_filename +>>> r2.rules_filename = 'r2-override.txt' +>>> r2.rules_filename +'r2-override.txt' +>>> r1.rules_filename 'plural6-rules.txt' ->>> r1.__class__.rules_filename = 'papayawhip.txt' +>>> r2.__class__.rules_filename +'plural6-rules.txt' +>>> r2.__class__.rules_filename = 'papayawhip.txt' >>> r1.rules_filename 'papayawhip.txt' ->>> r2.rules_filename -'papayawhip.txt' +>>> r2.rules_filename +'r2-overridetxt'
    -
  1. FIXME -
  2. -
  3. -
  4. +
  5. Each instance of the class inherits the rules_filename attribute with the value defined by the class. +
  6. Changing the attribute’s value in one instance does not affect other instances… +
  7. …nor does it change the class attribute. You can access the class attribute (as opposed to an individual instance’s attribute) by using the special __class__ attribute to access the class itself. +
  8. If you change the class attribute, all instances that are still inheriting that value (like r1 here) will be affected. +
  9. Instances that have overridden that attribute (like r2 here) will not be affected.

And now back to our show.