Skip to content

Commit 6c99359

Browse files
committed
Disambiguate the use of the term value in the example.
1 parent 256af16 commit 6c99359

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

docs/source/using_traitlets.rst

+9-8
Original file line numberDiff line numberDiff line change
@@ -95,29 +95,30 @@ Basic Example: Validating the Parity of a Trait
9595
from traitlets import HasTraits, TraitError, Int, Bool, validate
9696
9797
class Parity(HasTraits):
98-
value = Int()
98+
data = Int()
9999
parity = Int()
100100
101-
@validate('value')
102-
def _valid_value(self, proposal):
101+
@validate('data')
102+
def _valid_data(self, proposal):
103103
if proposal['value'] % 2 != self.parity:
104-
raise TraitError('value and parity should be consistent')
104+
raise TraitError('data and parity should be consistent')
105105
return proposal['value']
106106
107107
@validate('parity')
108108
def _valid_parity(self, proposal):
109109
parity = proposal['value']
110110
if parity not in [0, 1]:
111111
raise TraitError('parity should be 0 or 1')
112-
if self.value % 2 != parity:
113-
raise TraitError('value and parity should be consistent')
112+
if self.data % 2 != parity:
113+
raise TraitError('data and parity should be consistent')
114114
return proposal['value']
115115
116-
parity_check = Parity(value=2)
116+
117+
parity_check = Parity(data=2)
117118
118119
# Changing required parity and value together while holding cross validation
119120
with parity_check.hold_trait_notifications():
120-
parity_check.value = 1
121+
parity_check.data = 1
121122
parity_check.parity = 1
122123
123124
Notice how all of the examples above return

0 commit comments

Comments
 (0)