Question about math.pi is mutable

Chris Angelico rosuav at gmail.com
Fri Nov 6 14:40:38 EST 2015


On Sat, Nov 7, 2015 at 6:30 AM, Bartc <bc at freeuk.com> wrote:
> Is there no way then in Python to declare:
>
>    pi = 3.141519     # etc
>
> and make it impossible to override?

Nope. Even in C++, where classes can define certain things as const,
private, and other such restrictions, you can always get around them
by manipulating pointers appropriately. In Python, there's a
*convention* that a leading underscore means "private", but the
language doesn't enforce anything about it.

ChrisA



More information about the Python-list mailing list