Question about math.pi is mutable
Ben Finney
ben+python at benfinney.id.au
Fri Nov 6 22:43:44 EST 2015
Bartc <bc at freeuk.com> writes:
> Is there no way then in Python to declare:
>
> pi = 3.141519 # etc
>
> and make it impossible to override?
No, and it would be a bad thing if that were something a library author
could forbid.
Python assumes the programmers using it are consenting adults. Doing
harmful things is difficult but not forbidden.
Notably, the author of a library should not be forbidding the Pythonic
ability to change name bindings as needed.
If you want to have a different value bound to the name ‘math.pi’, and
you go ahead and explicitly ask to change that binding, the library
author has no business forbidding that.
--
\ “Software patents provide one more means of controlling access |
`\ to information. They are the tool of choice for the internet |
_o__) highwayman.” —Anthony Taylor |
Ben Finney
More information about the Python-list
mailing list