Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103473 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2016-02-25 12:19 +1100 |
| Last post | 2016-02-25 12:19 +1100 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
Import collisions (was Re: "from module import data; print(data)") Chris Angelico <rosuav@gmail.com> - 2016-02-25 12:19 +1100
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2016-02-25 12:19 +1100 |
| Subject | Import collisions (was Re: "from module import data; print(data)") |
| Message-ID | <mailman.112.1456363163.20994.python-list@python.org> |
On Thu, Feb 25, 2016 at 12:07 PM, Dan Stromberg <drsalists@gmail.com> wrote: > PS: Haskell seems better at the former than Python; Haskell tells you > if you import two identical symbols from two different places, when > you try to use one of them - not at import time. I believe in Python, > whichever symbol you import last, wins. Haskell does not warn you at > import time, which is fine. Not sure about OCaml or whatever else. In a sense, it's not the two imports that matter, but the situation that the second import statement is rebinding a name. Would it be possible to create a "mollyguard" import hook that snoops the globals of the importing module and raises an ImportWarning if it detects a rebind? Not that I've ever been in the situation of wanting one, but just as a point of intellectual curiosity. ChrisA
Back to top | Article view | comp.lang.python
csiph-web