[Python-Dev] Fwd: Change in repr of Decimal in 2.6 (original) (raw)

Terry Reedy tjreedy at udel.edu
Sun Jul 20 04:52:21 CEST 2008


Karen Tracey wrote:

Yeah, but the testcases are not quite that simple. They're often testing return values from functions and as much verifying that the type is correct as the value, so I think I'd have to change stuff like:

>>> f.clean('1') Decimal("1") to: >>> x = f.clean('1') >>> print type(x), x <class 'decimal.Decimal'> 1 right?

f.clean('1') == Decimal('1') True

Since 'True' is a keyword, and Guido is very reluctant to even add keywords, let alone change their spelling, I think you can depend on that working indefinitely. Similarly, if you now have

type(a) <type 'int'>

you test will fail in 3.0 which instead prints '<class 'int'>. But

type(a) is int True

will continue working.

Doctest has two quite different uses. One is to check text with interactive examples to make sure there are no mistakes in the examples. For that, printing representations is usually the natural style. Then one must accept that representations change faster that object behavior.

The other use is to check code. For that, the more stilted style is more future-proof. For text doing double duty as a formal reference and code test, I would go for cross-version dependability.

Terry Jan Reedy



More information about the Python-Dev mailing list