Closed ddamiani closed 5 years ago
That (admittedly nice) boolean repr may make users think it's safe to do is True
or is not False
-style comparisons, which will not work.
@ddamiani Sorry, I pushed out 3.3.0 this morning without checking for other open PRs.
Maybe it's safer then to have it return 0 or 1 as the repr, so no one tries doing is True
or is False
?
Merged with an additional change 313bb75724a25fec908c29805b990341cd765681 to print "true" or "false", which will hopefully be less ambiguous.
The default NTScalar unwrapping throws an exception when getting a boolean PV. There isn't an ntbool I assume because bool can't be subclassed? I add an ntbool class that is a subclass of int, but only can have a value of 0 or 1. It's repr also mimics the built-in boolean.
Example of it in action from the client-side
Also includes a small edit to the str method of ntwrappercommon so it will use the repr of the nt* class if it has one (like this ntbool does).