Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!us.feeder.erje.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'python': 0.09; 'directory)': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'terry': 0.09; '1:13': 0.16; 'entry.': 0.16; 'intended.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'reedy': 0.16; 'later': 0.16; 'wrote:': 0.17; 'tries': 0.17; 'jan': 0.18; 'module': 0.19; 'import': 0.21; 'posts': 0.23; "python's": 0.23; 'so.': 0.24; 'header:In-Reply-To:1': 0.25; 'header:User-Agent:1': 0.26; 'looks': 0.26; 'am,': 0.27; 'module.': 0.27; 'header:X-Complaints-To:1': 0.28; 'post': 0.28; 'writes': 0.30; 'resolution': 0.30; 'johnson': 0.32; 'directory,': 0.33; 'function.': 0.33; 'to:addr:python-list': 0.33; 'received:org': 0.36; 'depends': 0.36; 'does': 0.37; 'subject:: ': 0.38; 'fact': 0.38; 'to:addr:python.org': 0.39; 'header:Received:5': 0.40; 'first': 0.61; 'times': 0.63; 'more': 0.63; 'received:fios.verizon.net': 0.84; 'subject:Import': 0.84; 'forgotten': 0.91; 'rick': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Terry Reedy Subject: Re: PyWart: Import resolution order Date: Fri, 11 Jan 2013 08:35:37 -0500 References: <88bab977-ca49-487a-8fba-7d3350266d8d@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: pool-173-75-251-66.phlapa.fios.verizon.net User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:17.0) Gecko/17.0 Thunderbird/17.0 In-Reply-To: <88bab977-ca49-487a-8fba-7d3350266d8d@googlegroups.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: 23 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1357911401 news.xs4all.nl 6981 [2001:888:2000:d::a6]:36143 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:36620 On 1/11/2013 1:13 AM, Rick Johnson wrote: > > Python's import resolution order is terrible.[1] > > The fact that Python looks in the stdlib _first_ is not a good idea. And the fact is that it does not do so. The order depends on sys.path, and '' is the first entry. > It would seem more intuitive for a custom "math" module (living in > the current directory) to /override/ the stlib "math" module. Try it. This is a nuisance though, when not intended. Someone writes a random.py, and a year later in the same directory, an unrelated hopscotch.py, which tries to import random.exponential. The import fails and they post here, having forgotten about their own random.py, which does not have such a function. Posts like this happen a few times a year. -- Terry Jan Reedy