Question about math.pi is mutable
BartC
bc at freeuk.com
Sun Nov 8 19:11:58 EST 2015
On 09/11/2015 00:00, Ben Finney wrote:
> BartC <bc at freeuk.com> writes:
>
>> Is this typical Python code? Creating global objects in other modules
>> (or writing all over essential data structures in a library module).
>
> Not “creating global objects”, but changing the referent of a name in
> some other module. Yes, that's quite a common technique. Does that
> surprise you?
Changing the referent (I assume that just means assigning to it or
updating the associated value) wouldn't be a problem. Provided the name
was defined in that other module, because then it is a name the compiler
would know about.
(And, more importantly, someone reading the code in that module would
know about.)
> If it surprises you, hopefully you can learn some more Python with this
> new knowledge.
Yes, that it's more of a crazy language than it looks at first; I can
write a simple module like this:
pass
which looks like an empty module, yet for all I know will end up contain
hundreds of variables by the time it's run.
(I normally use my own language, that I call 'dynamic', but compared
with Python it might as well be carved in stone!)
--
Bartc
More information about the Python-list
mailing list