Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100522
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: does the order in which the modules are placed in a file matters ? |
| Date | 2015-12-17 03:49 +1100 |
| Message-ID | <mailman.18.1450284561.30845.python-list@python.org> (permalink) |
| References | <CACT3xuW5hdCUDaO4i-Fd8583j9CC0ATm3xHWYsqEXcbuW8_pgw@mail.gmail.com> <CAPTjJmqskNGthW9n4n_uP_6DbPeH-u5AoqKjxrV3vWg37V_0vw@mail.gmail.com> <ef78ab45c3944cf48d373d32947b9816@seaexchmbx03.olympus.F5Net.com> |
On Thu, Dec 17, 2015 at 3:42 AM, Dan Strohl <D.Strohl@f5.com> wrote: > For the general modules it doesn't matter, however using if you are using any non-standard packages, and If there are duplicate names in any of the modules and if you import them with a "*" (as some packages suggest), it can cause you to end up referring to an object you were not intending to. > > [chomp] > > Note, using * is dis-recommended, though pretty often done, for more information on using *, see: https://docs.python.org/2/tutorial/modules.html#importing-from-a-package This is exactly why (well, one of the reasons why) star imports are generally not recommended. There are a small number of modules that have promised to keep their namespaces clean in order to make this viable, but even there, it has issues of confusion. There are a few good places to use star imports, such as when you wrap one module in another; I would STRONGLY recommend against using two star imports in a single file, without being VERY sure of what you're doing. ChrisA
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: does the order in which the modules are placed in a file matters ? Chris Angelico <rosuav@gmail.com> - 2015-12-17 03:49 +1100
csiph-web