Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #104226
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: A mistake which almost went me mad |
| Date | Tue, 8 Mar 2016 03:40:31 +1100 |
| Lines | 32 |
| Message-ID | <mailman.28.1457368833.10335.python-list@python.org> (permalink) |
| References | <56d81044$0$19756$426a74cc@news.free.fr> <CAGuvt92tsr8hN+XnYB=FtmAXTDuM198FY92Sjjtw=P2QaVwjUg@mail.gmail.com> <20160303054822.342fb513@bigbox.christie.dr> <CAHVvXxRqkpHiWjiiUgi5JDgbMOdceTVEGBQzLP+dDy4dBuG3LQ@mail.gmail.com> <20160303125053.79e95bde@bigbox.christie.dr> <CALwzidmxMHF-jojjMbfT8g9V+Etngyf1qnnS+siCgWunamnqUw@mail.gmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=UTF-8 |
| X-Trace | news.uni-berlin.de XakF3o8eNwsGV3oIetajVw+C/LToodfH0AyunvhhcjfQ== |
| Return-Path | <rosuav@gmail.com> |
| 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; 'received:209.85.223': 0.03; 'python3': 0.05; 'pretend': 0.07; 'cc:addr:python-list': 0.09; 'dirname': 0.09; 'imports': 0.09; 'subject:which': 0.09; 'worked,': 0.09; 'explicitly': 0.15; 'importing': 0.15; 'packages.': 0.15; 'thu,': 0.15; '(and,': 0.16; '2016': 0.16; '__init__.py': 0.16; 'cc:name:python': 0.16; 'cwd': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'invoked.': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'reraise': 0.16; 'smtplib': 0.16; 'wrote:': 0.16; 'case.': 0.18; 'first.': 0.18; 'cc:2**0': 0.20; 'cc:addr:python.org': 0.20; 'prevent': 0.20; '2.x': 0.22; 'am,': 0.23; 'absolute': 0.23; 'import': 0.24; 'tim': 0.24; 'header:In-Reply-To:1': 0.24; 'module': 0.25; "doesn't": 0.26; 'message-id:@mail.gmail.com': 0.27; 'change,': 0.27; 'another.': 0.29; 'chase': 0.29; 'crash': 0.29; 'finds': 0.29; "i'm": 0.30; 'relative': 0.30; "can't": 0.32; 'usually': 0.33; 'directory,': 0.33; "i'll": 0.33; 'tue,': 0.34; 'received:google.com': 0.35; 'path': 0.35; 'something': 0.35; 'but': 0.36; 'should': 0.36; 'received:209.85': 0.36; 'subject:: ': 0.37; 'turn': 0.37; 'version': 0.38; 'received:209': 0.38; 'end': 0.39; 'why': 0.39; 'still': 0.40; 'protection': 0.60; 'your': 0.60; 'mar': 0.65; 'treat': 0.72; 'chrisa': 0.84; 'forced': 0.84; "it'd": 0.84; 'to:none': 0.91; 'besides,': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc; bh=PYiiQhACGm88SbDKWRUdIbgu9gn+koBgAKS9rB/kaMU=; b=RgwJLI173hrSGy3pU2Zja5+SQSgFJL+wJiFg+kunP3xdi26XPVKgnCd3NlPaiheMgk offqa6UDPRuRG50z03PIMMYL8JHDOLgajK01BRTvOZXpLWzmiDg1mge2tmdgzSLq1hsU Cj70dszVA1kTcOfgsOly4Sccui5uTPyh7UURjVsKngZhmJjq47XpKM3zLdZzMG/Mx7rW T44iXJ+20QWQ34frPFql7iWd6nzikJc50fZA09bhghXMWseCTx7RSWuxyozsY4F2/KEC nxj/S5rvR7Os2xfftv0nsYd6yMwO/ouTWGAmzj79qaOWvsImHO308MuC3uD1Rjv0z28C 5hEg== |
| X-Google-DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:cc; bh=PYiiQhACGm88SbDKWRUdIbgu9gn+koBgAKS9rB/kaMU=; b=UDczieX85VQvbt6rxUnJmt7vHlgq+O/9vBiOq2k/yQucvIurVqJ8N7SlqqxRPPtn0b fPK38ZLpfaoKOjg0Rv/WQsfKZs5YyRsCzcoqRMvGq+x1tcAuPoBL/+k/x1hM4bxSnzH/ r1dASmWJdGMGJkvM1z6UC3bnGfsFePFEH23W4arz8liPk6uCoyaQGPoQxvidilMpUkMH f1nH+A1iiakZdBocLLY+VqZW/eH/fMLRa1zgqHJwOkeEEjFYiSdQJ0ZBS1uGLHJTUsVU AmTV2mlUh0C3qQ+2UZ8VEEy5iRkSSh0Nk+y3PvbADcLjUtZiuyHq5wHn+SWwzNz8VKmn bGUw== |
| X-Gm-Message-State | AD7BkJK3JtP//rurwWs8hstQJnoJluft63kFMujVevfZ8kSqrGVcs2FkUUZhF8kVhBZja0FVY4uFWyzCp8SvEQ== |
| X-Received | by 10.107.47.163 with SMTP id v35mr20159108iov.19.1457368831192; Mon, 07 Mar 2016 08:40:31 -0800 (PST) |
| In-Reply-To | <CALwzidmxMHF-jojjMbfT8g9V+Etngyf1qnnS+siCgWunamnqUw@mail.gmail.com> |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Xref | csiph.com comp.lang.python:104226 |
Show key headers only | View raw
On Tue, Mar 8, 2016 at 3:19 AM, Ian Kelly <ian.g.kelly@gmail.com> wrote: > On Thu, Mar 3, 2016 at 11:50 AM, Tim Chase > <python.list@tim.thechases.com> wrote: >> I think that relative imports should ameliorate this, as I usually >> hit it when I'm using smtplib which in turn imports "email" (and, in >> 2.x when it found my local email.py would crash and burn). If it used >> a relative import that forced it to find the one in the stdlib, it >> should(?) prevent it from finding my local version first. > > Relative imports only work inside packages. You can't use a relative > import to import one top-level module from another. > > Besides, the relative import doesn't help to disambiguate in this > case. The absolute path of the stdlib email module is "email". The > absolute path of the module in your CWD is also "email". Why should a > relative import prefer one over the other? So I would think that even > if it worked, it would still just end up importing the first one it > finds on your sys.path. So the solution is to treat the current directory as a pseudo-package. It'd be a backward-incompatible change, so it would need to be explicitly invoked. Something like: python3 -p somefile.py which would pretend to create an __init__.py in the current directory, change to the parent, and "from dirname import somefile". I mentioned this one time before, but it got kinda missed; I think I'll reraise it on python-ideas. It's a protection on par with not having the current directory in $PATH. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
A mistake which almost went me mad "ast" <nomail@invalid.com> - 2016-03-03 11:21 +0100
Re: A mistake which almost went me mad Chris Angelico <rosuav@gmail.com> - 2016-03-03 21:31 +1100
Re: A mistake which almost went me mad Nick Sarbicki <nick.a.sarbicki@gmail.com> - 2016-03-03 10:43 +0000
Re: A mistake which almost went me mad Tim Golden <mail@timgolden.me.uk> - 2016-03-03 10:48 +0000
Re: A mistake which almost went me mad Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2016-03-04 19:19 +1300
Re: A mistake which almost went me mad Steven D'Aprano <steve@pearwood.info> - 2016-03-03 23:57 +1100
Re: A mistake which almost went me mad Tim Chase <python.list@tim.thechases.com> - 2016-03-03 05:48 -0600
Re: A mistake which almost went me mad Oscar Benjamin <oscar.j.benjamin@gmail.com> - 2016-03-03 16:29 +0000
Re: A mistake which almost went me mad Rob Gaddi <rgaddi@highlandtechnology.invalid> - 2016-03-03 17:53 +0000
Re: A mistake which almost went me mad Tim Chase <python.list@tim.thechases.com> - 2016-03-03 12:50 -0600
Re: A mistake which almost went me mad Ian Kelly <ian.g.kelly@gmail.com> - 2016-03-07 09:19 -0700
Re: A mistake which almost went me mad Random832 <random832@fastmail.com> - 2016-03-07 11:28 -0500
Re: A mistake which almost went me mad Chris Angelico <rosuav@gmail.com> - 2016-03-08 03:40 +1100
Re: A mistake which almost went me mad Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-09 08:34 -0800
Re: A mistake which almost went me mad Rustom Mody <rustompmody@gmail.com> - 2016-03-09 22:13 -0800
Re: A mistake which almost went me mad Rick Johnson <rantingrickjohnson@gmail.com> - 2016-03-10 16:54 -0800
csiph-web