Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsfeed.freenet.ag!newsfeed0.kamp.net!newsfeed.kamp.net!feeder1.cambriumusenet.nl!82.197.223.108.MISMATCH!feeder2.cambriumusenet.nl!feed.tweaknews.nl!194.109.133.81.MISMATCH!newsfeed.xs4all.nl!newsfeed2.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'skip:[ 20': 0.04; 'explicitly': 0.05; 'that?': 0.05; 'subject:Python': 0.06; 'rename': 0.07; 'falls': 0.09; '-tkc': 0.16; 'finds': 0.16; 'from:addr:python.list': 0.16; 'from:addr:tim.thechases.com': 0.16; 'from:name:tim chase': 0.16; 'hrm.': 0.16; 'imports': 0.16; 'internally': 0.16; 'jumps': 0.16; 'subject: \n ': 0.16; 'subject:dependencies': 0.16; 'subject:import': 0.16; 'wrote:': 0.18; 'library': 0.18; 'module': 0.19; 'import': 0.22; 'error': 0.23; 'certainly': 0.24; 'module,': 0.24; "i've": 0.25; 'header :In-Reply-To:1': 0.27; 'point': 0.28; '(which': 0.31; "d'aprano": 0.31; 'implicit': 0.31; 'steven': 0.31; 'this.': 0.32; 'python.org': 0.32; 'subject:the': 0.34; 'could': 0.34; 'but': 0.35; 'module.': 0.36; 'charset:us-ascii': 0.36; "i'll": 0.36; 'received:10': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'to:addr:python.org': 0.39; 'enough': 0.39; 'users': 0.40; 'even': 0.60; 'subject:"': 0.60; 'times': 0.62; 'obvious': 0.74; 'happened.': 0.84; 'shadow': 0.84; 'subject:history': 0.84 X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-Sender-Id: wwwh|x-authuser|tim@thechases.com X-MC-Relay: Neutral X-MailChannels-SenderId: wwwh|x-authuser|tim@thechases.com X-MailChannels-Auth-Id: wwwh X-MC-Loop-Signature: 1416691477247:2409396486 X-MC-Ingress-Time: 1416691477247 Date: Sat, 22 Nov 2014 15:27:14 -0600 From: Tim Chase To: python-list@python.org Subject: Re: PyWart: "Python's import statement and the history of external dependencies" In-Reply-To: <547080a0$0$12981$c3e8da3$5496439d@news.astraweb.com> References: <066c46c8-a04d-4489-b15a-b603c1b1818b@googlegroups.com> <8661e407-4472-4208-97c2-f666f6502c67@googlegroups.com> <547080a0$0$12981$c3e8da3$5496439d@news.astraweb.com> X-Mailer: Claws Mail 3.8.1 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-AuthUser: tim@thechases.com 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: , Newsgroups: comp.lang.python Message-ID: Lines: 35 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416691489 news.xs4all.nl 2833 [2001:888:2000:d::a6]:47350 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81302 On 2014-11-22 23:25, Steven D'Aprano wrote: > Having said that, it's not fair to blame the user for shadowing > standard library modules: > > - All users start off as beginners, who may not be aware that this > is even a possibility; While it's one thing to explicitly shadow a module (creating your own module named "calendar"; if you need the stdlib module, you know it and have to rename your local one), the implicit shadowing has stung me a number of times. I'll unthinkingly create an "email.py" and then need to send email so I'll import smtplib (which internally imports stdlib's email.py but it finds my local email.py) and everything falls over. The error messages don't make it obvious what happened. I've been burned enough times that I now know not to do this. But it was certainly burned into my mind after the 3rd time it happened. > > And after all that, it would still fail if you happened to want to > > import both "calendar" modules into the same module. > > __path__ = [] > import calendar > __path__ = ['my/python/modules'] > import calendar as mycalendar Hrm. Never knew this. Could you point me at some docs on that? (searching for "__path__" on python.org isn't turning up much that jumps out at me as being correlated) -tkc