Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.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.064 X-Spam-Evidence: '*H*': 0.87; '*S*': 0.00; 'subject: -- ': 0.07; 'os.path': 0.09; 'jan': 0.12; 'url:file': 0.16; 'wrote:': 0.18; 'import': 0.22; 'header:In-Reply-To:1': 0.27; 'message- id:@mail.gmail.com': 0.30; "d'aprano": 0.31; 'steven': 0.31; 'url:python': 0.33; 'but': 0.35; 'received:google.com': 0.35; 'entry': 0.36; 'subject:?': 0.36; 'url:org': 0.36; 'work?': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; '2015': 0.84; 'url:cpython': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; bh=7aS+PAFtqaC4EaUSTWr2FktCFMixh9nBC7rFJEF8b/o=; b=JG7KrAIhIOGtUW38dAi5pGeuoJ0hKagW02lxERggRr/ciLm5C5xNvV7FZF25O3NxJq 5MQRUENHHvsLkCARpc/ToeE5l1xMOnxL8xYJG+M3q71bYsbvi1ACV3sbfKZerdKms+rC bvVHmQxSaqi2Kgq5oHCoAg0eIXZwdDqq0rYP3y/yjhEg46LsLVhrVcr3rOOmZnVVMggy OKUISrKmI4oB7bFaMaXZOBWjhBR8QebPNXVKSHdaOvmV43M0hwvawNxqvBlJh6uAe8Fz FI+7vwhGBFwWLkOK7228p5+BtDIdkOy5b3AJfk1mCsJyh9rY6NsE8jXTuZCEcPuw46o5 REhw== X-Received: by 10.66.166.171 with SMTP id zh11mr41759234pab.85.1421042486043; Sun, 11 Jan 2015 22:01:26 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <54b35c3d$0$2738$c3e8da3$76491128@news.astraweb.com> References: <54b35c3d$0$2738$c3e8da3$76491128@news.astraweb.com> From: Ian Kelly Date: Sun, 11 Jan 2015 23:00:45 -0700 Subject: Re: importing os.path -- why does it work? To: Python 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1421042495 news.xs4all.nl 2964 [2001:888:2000:d::a6]:44392 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:83596 On Sun, Jan 11, 2015 at 10:31 PM, Steven D'Aprano wrote: > But bizarrely, you can import os.path this way! > > py> import os.path > py> os.path > > py> os.__package__ > '' > > > > By what wizardry does this work? By the wizardry of adding an entry to sys.modules. https://hg.python.org/cpython/file/8b3c609f3f73/Lib/os.py#l112