Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder2.hal-mli.net!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'package,': 0.03; 'importing': 0.04; 'case.': 0.05; 'paths': 0.05; 'python': 0.09; 'explanation': 0.09; 'friday,': 0.09; 'ide': 0.09; 'imported': 0.09; 'imports': 0.09; 'scripting': 0.09; 'throw': 0.09; 'to:addr:comp.lang.python': 0.09; 'translations': 0.09; 'cc:addr :python-list': 0.10; 'gui': 0.11; 'language,': 0.11; 'language': 0.14; 'clash': 0.16; "package's": 0.16; 'paths.': 0.16; 'renamed': 0.16; 'later': 0.16; 'wrote:': 0.17; 'instance': 0.17; 'module,': 0.17; 'package.': 0.17; 'tries': 0.17; 'jan': 0.18; 'module': 0.19; 'math': 0.20; 'import': 0.21; '2.x': 0.22; 'explicit': 0.22; 'implicit': 0.22; 'cc:2**0': 0.23; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; '(most': 0.27; 'correct': 0.28; 'chris': 0.28; 'helpful.': 0.29; 'usually': 0.30; 'fri,': 0.30; 'relative': 0.30; 'gets': 0.32; 'johnson': 0.32; 'could': 0.32; '11,': 0.33; 'strict': 0.33; 'received:google.com': 0.34; 'exist': 0.35; 'from:addr:googlemail.com': 0.35; 'path': 0.35; 'pm,': 0.35; 'sometimes': 0.35; 'received:209.85': 0.35; 'but': 0.36; 'modules': 0.36; 'enough': 0.36; 'ok,': 0.37; 'does': 0.37; 'uses': 0.37; 'why': 0.37; 'received:209': 0.37; 'received:209.85.216': 0.37; 'subject:: ': 0.38; 'some': 0.38; 'where': 0.40; 'think': 0.40; 'your': 0.60; 'skip:u 10': 0.60; 'containing': 0.61; 'first': 0.61; 'kind': 0.61; 'is.': 0.62; 'times': 0.63; 'skip:n 10': 0.63; 'decided': 0.65; 'choose': 0.65; 'commercial': 0.73; '"look': 0.84; '2013': 0.84; ':).': 0.84; 'first?': 0.84; 'subject:Import': 0.84; 'rick': 0.91 X-Received: by 10.50.34.167 with SMTP id a7mr1004139igj.5.1358049383363; Sat, 12 Jan 2013 19:56:23 -0800 (PST) Newsgroups: comp.lang.python Date: Sat, 12 Jan 2013 19:56:22 -0800 (PST) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=123.192.32.215; posting-account=5JdMBQoAAABHnS4mjpqEzxnmWtgiiVNw References: <88bab977-ca49-487a-8fba-7d3350266d8d@googlegroups.com> <2e407be7-2812-4c21-b91c-58e39b474bf7@googlegroups.com> User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-IP: 123.192.32.215 MIME-Version: 1.0 Subject: Re: PyWart: Import resolution order From: 88888 Dihedral To: comp.lang.python@googlegroups.com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Cc: Python X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Message-ID: Lines: 86 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1358049392 news.xs4all.nl 6982 [2001:888:2000:d::a6]:37044 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36720 Ian=E6=96=BC 2013=E5=B9=B41=E6=9C=8812=E6=97=A5=E6=98=9F=E6=9C=9F=E5=85=ADU= TC+8=E4=B8=8B=E5=8D=883=E6=99=8236=E5=88=8643=E7=A7=92=E5=AF=AB=E9=81=93=EF= =BC=9A > On Fri, Jan 11, 2013 at 10:28 PM, Rick Johnson >=20 > wrote: >=20 > > On Friday, January 11, 2013 12:30:27 AM UTC-6, Chris Angelico wrote: >=20 > >> Why is it better to import from the current directory first? >=20 > > >=20 > > 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 a= ll times) packages will contain many sub-modules that need to be imported i= nto 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 sens= e. >=20 >=20 >=20 > And again, in Python 2.x this is already the case. When importing in >=20 > a package, it tries to do a relative import before it even looks at >=20 > sys.path. >=20 >=20 >=20 > > I think if python where *strict* about full paths for non-builtins, the= n we would be in a better place. >=20 >=20 >=20 > And again, in Python 3, where implicit relative imports have been >=20 > removed from the language, it already is strict about using full >=20 > paths. You can still do relative imports, but you have to be explicit >=20 > about them. >=20 >=20 >=20 > > For instance you could create a package named "chris" and then have a m= odule named math exist inside. Alternatively if you choose to be a non-prof= essional and create a math module without a containing package, python woul= d throw the module into the default "lib" package. The only way you could a= ccess your math module now would be by using the path "lib.math". >=20 >=20 >=20 > What if I create a package named "math"? Does that also automatically >=20 > get renamed to "lib.math"? How is it decided what package names are >=20 > proper; is it just because it happens to clash with a stdlib name that >=20 > the package gets magically renamed? >=20 >=20 >=20 > What if I create a package, and then later a module with the same name >=20 > happens to be added to the stdlib? My program that uses the package >=20 > just breaks because it no longer imports the correct thing? >=20 >=20 >=20 > > Damn i am full of good ideas! >=20 >=20 >=20 > Your ideas might be better if you first spent some time gaining a >=20 > better understanding of how the language works as is. OK, I think to develop a GUI with auto-code=20 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=20 commercial part.=20