File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 66<overview >
77<p >The ability to override the class dictionary using a <code >__slots__</code > declaration
88is supported only by new-style classes. When you add a <code >__slots__</code > declaration to an
9- old-style class it just creates a class attribute called ' __slots__' .</p >
9+ old-style class it just creates a class attribute called < code > __slots__</ code > .</p >
1010
1111</overview >
1212<recommendation >
@@ -17,9 +17,9 @@ You can convert an old-style class to a new-style class by inheriting from <code
1717</recommendation >
1818<example >
1919<p >In the following example the <code >KeyedRef</code > class is an old-style class (no inheritance). The
20- <code >__slots__</code > declaration in this class creates a class attribute called '__slots__', the class
2120dictionary is unaffected. The <code >KeyedRef2</code > class is a new-style class so the
2221<code >__slots__</code > declaration causes special compact attributes to be created for each name in
22+ <code >__slots__</code > declaration in this class creates a class attribute called <code >__slots__</code >, the class
2323the slots list and saves space by not creating attribute dictionaries.</p >
2424
2525<sample src =" SlotsInOldStyleClass.py" />
You can’t perform that action at this time.
0 commit comments