Closed conqp closed 6 years ago
I don't believe it's possible to have an instance of Decimal that has a value None
:
>>> import decimal
>>> x = decimal.Decimal()
>>> x
Decimal('0')
>>>
If the value of the reference in an expression were None
then it would not allow methods such as toxml()
.
Generally speaking the concept of a typed nullable value doesn't really fit with Python's data structures. I think PyXB's doing the only thing it can do here.
The API could be changed to, e.g.:
>>> type(struct.decimal_field)
None
>>> struct.isNil.decimal_field()
True
>>> struct.toxml.decimal_field()
<element xsi:nil=true ...
Guess this is is a bit out of scope for the current state of pyxb.
Currently e.g. a nilable
decimal
field with valuexsd:nil
will returnDecimal('0')
. It'd be more convenient (for me) if it returnedNone
instead.