Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!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.011 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:Python': 0.06; 'explicit': 0.07; 'linux,': 0.07; 'paths': 0.07; 'sys': 0.07; '22,': 0.09; 'method,': 0.09; 'windows,': 0.09; 'cc:addr:python- list': 0.11; 'python': 0.11; '*any*': 0.16; 'bsd,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hard- code': 0.16; 'path.': 0.16; 'resolutions,': 0.16; 'subject:dependencies': 0.16; 'subject:import': 0.16; 'throw': 0.16; 'unchanged': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'module': 0.19; 'mechanism': 0.19; 'work,': 0.20; 'import': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'message- id:@mail.gmail.com': 0.30; 'code': 0.31; 'os,': 0.31; 'file': 0.32; 'cases': 0.33; 'mac': 0.33; 'subject:the': 0.34; 'johnson': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'words,': 0.36; 'method': 0.36; 'nov': 0.38; 'expect': 0.39; 'realize': 0.39; 'use.': 0.39; 'how': 0.40; 'subject:"': 0.60; 'most': 0.60; 'tell': 0.60; 'new': 0.61; 'advanced': 0.63; 'name': 0.63; 'more': 0.64; 'taking': 0.65; 'techniques': 0.66; 'details,': 0.68; "today's": 0.70; 'day': 0.76; 'heavy': 0.81; './configure': 0.84; 'itself?': 0.84; 'situations,': 0.84; 'subject:history': 0.84; 'on?': 0.91; 'to:none': 0.92; 'rick': 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 :content-type; bh=UjlQVknHNfkpUiat4rPjgcrk48Zhdq2y+pXN1oTEq5M=; b=Qb3RB+Yuu7qt+0ONXhEPS4FCKnI40UYienIQUfssqUicERQF81XgXJmRjpplOhn00f Q0Uv0tKXOEGzmAGOEh5BCGGKboEw1L5h5vvIX2CkwUaEqfRMj9k/xtKJnhtmcCPsSnaV +9lHtmGqEzOXBwqg6kRQJ4ADLJy2bWar7Bgu9lNlhEAIdc5PP+6IHTER+ZKzMeX4O9Ej KkGgErCuiQqfw2iCTASupJxebMXSierpWN8z4SznLZGxEZ9Vi8dpYF0j6v3NCyOPPqOI x3jFtCwOf5E6Q7v5NbtJxB4wqgnHTAtdRQzD6lMuVKNRXFaLvtBV9G444JmxiKbqU5nG WB2A== MIME-Version: 1.0 X-Received: by 10.50.178.212 with SMTP id da20mr902010igc.34.1416613954178; Fri, 21 Nov 2014 15:52:34 -0800 (PST) In-Reply-To: References: <066c46c8-a04d-4489-b15a-b603c1b1818b@googlegroups.com> <8661e407-4472-4208-97c2-f666f6502c67@googlegroups.com> <0bbe1c60-2b29-40f6-96e1-ac777f0c276f@googlegroups.com> <08867178-abb6-4703-9ac5-2a53acb5d227@googlegroups.com> Date: Sat, 22 Nov 2014 10:52:33 +1100 Subject: Re: PyWart: "Python's import statement and the history of external dependencies" From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 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: 31 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416614372 news.xs4all.nl 2893 [2001:888:2000:d::a6]:44011 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81256 On Sat, Nov 22, 2014 at 10:21 AM, Rick Johnson wrote: > 1. Use the historical "implicit import" mechanism for most day > to day imports, and let Python do all the heavy lifting. > > 2. Use the new "explicit import" mechanism for advanced name > resolutions, but realize that since you are now taking > control of import, so you must do more work, and you must be > "exhaustively explicit" about *where* Python searches. In other words, what you want is: # today's method, import based on search path import sys # new explicit path method import '/usr/local/lib/python3.5/lib-dynload/math.cpython-35m.so' Can you tell me, please, how this is going to work for *any* system other than the one it was built on? One of the reasons I write Python code is because I expect it to work unchanged on Windows, Linux, Mac OS, BSD, OS/2, uPy, and any other platform I care to throw it onto. If I want to hard-code all the details, I might as well write C code and at least take advantage of ./configure to work out the right paths for me. There are a VERY VERY few cases where you really do want to import a module from a specific file path. For those situations, there are already techniques you can use. Why change the behaviour of import itself? ChrisA