PyMyth: Global variables are evil... WRONG!

Tim Chase python.list at
Wed Nov 13 04:22:12 CET 2013

On 2013-11-12 18:45, Rick Johnson wrote:
> "math.pi" should be "math.PI".

It's a real shame that this fails:

  >>> math.PI = math.pi


> and PI should be a CONSTANT. And not just a pseudo constant, but a
> REAL constant that cannot be changed.

How much precision do you want?  Perhaps you really do want do just
use because you know you only have 2-3 places of precision in your
other numbers:

  math.pi = 3.14

Or maybe you want to monkey-patch in a fraction/decimal instead for
greater precision:

 math.pi = decimal.Decimal('3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679')

It comes back to Python being a language for consenting adults.


More information about the Python-list mailing list