Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #36720
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-01-12 19:56 -0800 |
| References | <88bab977-ca49-487a-8fba-7d3350266d8d@googlegroups.com> <mailman.388.1357886143.2939.python-list@python.org> <2e407be7-2812-4c21-b91c-58e39b474bf7@googlegroups.com> <mailman.437.1357976236.2939.python-list@python.org> |
| Subject | Re: PyWart: Import resolution order |
| From | 88888 Dihedral <dihedral88888@googlemail.com> |
| Message-ID | <mailman.458.1358049392.2939.python-list@python.org> (permalink) |
Ian於 2013年1月12日星期六UTC+8下午3時36分43秒寫道: > On Fri, Jan 11, 2013 at 10:28 PM, Rick Johnson > > <rantingrickjohnson@gmail.com> wrote: > > > On Friday, January 11, 2013 12:30:27 AM UTC-6, Chris Angelico wrote: > > >> Why is it better to import from the current directory first? > > > > > > Opps. I was not explicit enough with my explanation :). I meant, "look in the current directory FIRST when in a package". Since many times (most all times) packages will contain many sub-modules that need to be imported into the package's main.py module, and sometimes these modules will have the same name as a stdlib module, then looking in the package FIRST makes sense. > > > > And again, in Python 2.x this is already the case. When importing in > > a package, it tries to do a relative import before it even looks at > > sys.path. > > > > > I think if python where *strict* about full paths for non-builtins, then we would be in a better place. > > > > And again, in Python 3, where implicit relative imports have been > > removed from the language, it already is strict about using full > > paths. You can still do relative imports, but you have to be explicit > > about them. > > > > > For instance you could create a package named "chris" and then have a module named math exist inside. Alternatively if you choose to be a non-professional and create a math module without a containing package, python would throw the module into the default "lib" package. The only way you could access your math module now would be by using the path "lib.math". > > > > What if I create a package named "math"? Does that also automatically > > get renamed to "lib.math"? How is it decided what package names are > > proper; is it just because it happens to clash with a stdlib name that > > the package gets magically renamed? > > > > What if I create a package, and then later a module with the same name > > happens to be added to the stdlib? My program that uses the package > > just breaks because it no longer imports the correct thing? > > > > > Damn i am full of good ideas! > > > > Your ideas might be better if you first spent some time gaining a > > better understanding of how the language works as is. OK, I think to develop a GUI with auto-code translations in an IDE with python as the CAD/CAM scripting language can be helpful. But usually this kind of sotware projects is in the commercial part.
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
PyWart: Import resolution order Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-10 22:13 -0800
Re: PyWart: Import resolution order Chris Angelico <rosuav@gmail.com> - 2013-01-11 17:30 +1100
Re: PyWart: Import resolution order Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-11 21:28 -0800
Re: PyWart: Import resolution order Chris Angelico <rosuav@gmail.com> - 2013-01-12 17:03 +1100
Re: PyWart: Import resolution order Ian Kelly <ian.g.kelly@gmail.com> - 2013-01-12 00:36 -0700
Re: PyWart: Import resolution order 88888 Dihedral <dihedral88888@googlemail.com> - 2013-01-12 19:56 -0800
Re: PyWart: Import resolution order 88888 Dihedral <dihedral88888@googlemail.com> - 2013-01-12 19:56 -0800
Re: PyWart: Import resolution order Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-11 21:28 -0800
Re: PyWart: Import resolution order alex23 <wuwei23@gmail.com> - 2013-01-12 19:23 -0800
Re: PyWart: Import resolution order Terry Reedy <tjreedy@udel.edu> - 2013-01-11 08:35 -0500
Re: PyWart: Import resolution order Michael Torrie <torriem@gmail.com> - 2013-01-11 10:53 -0700
Re: PyWart: Import resolution order Rick Johnson <rantingrickjohnson@gmail.com> - 2013-01-11 20:50 -0800
Re: PyWart: Import resolution order alex23 <wuwei23@gmail.com> - 2013-01-11 23:44 -0800
csiph-web