On 2019-11-03 16:34:39 -0800, jf...@ms4.hinet.net wrote:
> I innocently thought that when import module through "from test import
> *", I am working on test's globals under REPL. I didn't noticed the
> REPL has its own globals.

Well, you imported every global from test. So you are (kind of) working
on those globals, or at least the objects they are referencing.

In the real world, when you import a car from Germany, the car is now in
your country, but you are not in Germany. Even if you import all the
cars from Germany, you are still not in Germany.

It's the same way in Python.

Well, kind of. One important difference is that when you import a car
from Germany, that car is no longer in Germany. But when you import a
symbol from a Python module, that symbol still exists in that module.
You just have a second symbol in your namespace referencing the same
object (as Cameron pointed out).

        hp

-- 
   _  | Peter J. Holzer    | Story must make more sense than reality.
|_|_) |                    |
| |   | h...@hjp.at         |    -- Charles Stross, "Creative writing
__/   | http://www.hjp.at/ |       challenge!"

Attachment: signature.asc
Description: PGP signature

-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to