Question about math.pi is mutable

Antoon Pardon antoon.pardon at rece.vub.ac.be
Mon Nov 9 09:49:48 EST 2015


Op 07-11-15 om 04:43 schreef Ben Finney:
> 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.

I find that to be contradictory. Why should you make something difficult
if you are consenting adults? I also find it important that consenting
adults can choose in how far they can consent. This whole idea of python
assuming we are consenting adults and thus making it impossible to not
consent seems weird.

> Notably, the author of a library should not be forbidding the Pythonic
> ability to change name bindings as needed.

If the author of a library doesn't wish to consent to this I don't see
what is wrong with that.

> 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.

I disagree. Maybe the author is willing to freely give support but only
on the condition that the user used the library as it was largely intended.
I see no more reason to allow math.pi to be rebound to another value as
to allow True, False or None to be rebound.

So why should we allow the language designers to forbid the latter but
library authors not the former?




More information about the Python-list mailing list