Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #103473
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Import collisions (was Re: "from module import data; print(data)") |
| Date | 2016-02-25 12:19 +1100 |
| Message-ID | <mailman.112.1456363163.20994.python-list@python.org> (permalink) |
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 comp.lang.python | Previous | Next | Find similar | Unroll thread
Import collisions (was Re: "from module import data; print(data)") Chris Angelico <rosuav@gmail.com> - 2016-02-25 12:19 +1100
csiph-web