File tree 2 files changed +25
-2
lines changed
2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change 20
20
@$(SPHINXBUILD ) -M $@ " $( SOURCEDIR) " " $( BUILDDIR) " $(SPHINXOPTS ) $(O )
21
21
22
22
autobuild :
23
- sphinx-autobuild -p 9999 -b html " $( SOURCEDIR) " $(BUILDDIR ) /html
23
+ sphinx-autobuild --port 9999 -b html " $( SOURCEDIR) " $(BUILDDIR ) /html
Original file line number Diff line number Diff line change @@ -137,7 +137,8 @@ Implementors are not required to implement methods with defaults:
137
137
# get_all(self) will automatically be copied from the interface default.
138
138
139
139
Default implementations should always be implemented in terms of other
140
- interface methods.
140
+ interface methods. This ensures that the default is valid for any
141
+ implementation of the interface.
141
142
142
143
In Python 3, :class: `default ` will show a warning if a default implementation
143
144
uses non-interface members of an object:
@@ -173,6 +174,28 @@ of ``get_all``:
173
174
Consider changing ReadOnlyMapping.get_all or making these attributes part of ReadOnlyMapping.
174
175
class ReadOnlyMapping(interface.Interface):
175
176
177
+ Default Properties
178
+ ******************
179
+
180
+ :class: `default ` and :class: `property ` can be used together to create default properties:
181
+
182
+ .. code-block :: python
183
+
184
+ class ReadOnlyMappingWithSpecialKey (interface .Interface ):
185
+
186
+ def get (self , key ):
187
+ pass
188
+
189
+ @interface.default
190
+ @ property
191
+ def special_key (self ):
192
+ return self .get(' special_key' )
193
+
194
+ .. note ::
195
+
196
+ The order of decorators in the example above is important: ``@default `` must
197
+ go above ``@property ``.
198
+
176
199
Interface Subclassing
177
200
~~~~~~~~~~~~~~~~~~~~~
178
201
You can’t perform that action at this time.
0 commit comments