Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.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.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'subject:IDLE': 0.04; 'yet.': 0.04; 'paths': 0.07; '#include': 0.09; 'builtin': 0.09; 'latter': 0.09; 'skip:/ 10': 0.09; 'cc:addr :python-list': 0.11; 'python': 0.11; 'random': 0.14; '(it': 0.16; '3.3,': 0.16; 'directory)': 0.16; 'former,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'idle,': 0.16; 'invokes': 0.16; 'itself).': 0.16; 'modules,': 0.16; 'namespace.': 0.16; 'quick!': 0.16; 'rather,': 0.16; 'subject: \n ': 0.16; 'sys.path': 0.16; 'wrote:': 0.18; 'library': 0.18; 'variable': 0.18; 'wed,': 0.18; 'module': 0.19; 'basically': 0.19; 'starts': 0.20; 'import': 0.22; 'aug': 0.22; 'separate': 0.22; 'cc:addr:python.org': 0.22; 'affects': 0.24; 'directory.': 0.24; 'module,': 0.24; '(or': 0.24; 'cc:2**0': 0.24; 'equivalent': 0.26; 'least': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'possibility': 0.29; 'message-id:@mail.gmail.com': 0.30; '(which': 0.31; 'code': 0.31; "d'aprano": 0.31; 'directory,': 0.31; 'idea,': 0.31; 'lot.': 0.31; 'steven': 0.31; 'subject:what': 0.31; 'probably': 0.32; 'stuff': 0.32; 'run': 0.32; 'maybe': 0.34; 'could': 0.34; 'subject:with': 0.35; "can't": 0.35; 'problem.': 0.35; 'something': 0.35; 'one,': 0.35; 'point.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'idle': 0.36; 'library.': 0.36; 'done': 0.36; 'useful': 0.36; 'subject:?': 0.36; 'application': 0.37; 'two': 0.37; 'project': 0.37; 'expected': 0.38; 'files': 0.38; 'sure': 0.39; 'remove': 0.60; "you'll": 0.62; "you've": 0.63; 'name': 0.63; 'more': 0.64; 'chance': 0.65; 'worth': 0.66; 'yourself': 0.78; 'affected.': 0.84; 'to:none': 0.92; '410': 0.95; 'serious': 0.97 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=tcfCqufA0HIvzVgNHoLlFbtlLywyeUle4SFrTbB1F04=; b=lXsxRC2YQbKGsQqyZEDQUCuOxCCTSZ6CnqgNSWID4XItJd7uXApRGGt9nfjeU9dDNv EghF5Gu0n+qpxdUkKSX8mVu6FV21Us6CHWywBMrS/hMt885ZogtqqA9HT2OTZjNecGMp lQAA99573UcyhhHfrcI30XFSW8GXSx4KsbXCH3ZBZyhfIdfsYME3/CaUEQlgt4Yxyx0J VkeTJ5nb1OUdLwe7g1HAppOvWv2NlXVVQ3JZnKeKoH8bv7EexyFvKbYUdD8mVIjGIJiu mk6Y1ZfXi8pq8OFaDVoMe8quti8kzH51tbd2EGxq0M0Gzg1SrBix5tz6sdul8d31fP0B nO+w== MIME-Version: 1.0 X-Received: by 10.43.94.73 with SMTP id bx9mr31606782icc.19.1409098737479; Tue, 26 Aug 2014 17:18:57 -0700 (PDT) In-Reply-To: <53fd1fd3$0$30001$c3e8da3$5496439d@news.astraweb.com> References: <4eec9365-4103-4474-a47f-ea665b265b1e@googlegroups.com> <5a9b5715-382b-4a6b-be90-c535ad14740a@googlegroups.com> <53fd1fd3$0$30001$c3e8da3$5496439d@news.astraweb.com> Date: Wed, 27 Aug 2014 10:18:57 +1000 Subject: Re: IDLE has suddenly become FAWLTY - so should I be hitting it with a big stick, or what? 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: 46 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1409098740 news.xs4all.nl 2936 [2001:888:2000:d::a6]:35433 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:77088 On Wed, Aug 27, 2014 at 10:01 AM, Steven D'Aprano wrote: > Gregory Ewing wrote: > >> Although shadowing builtin module names is never a good >> idea, either! > > /s/builtin/standard library/ > > Quick! Name all the standard library modules, stat! > > In Python 3.3, there are something like 410 modules in the standard library. > There's a reasonable chance that you've shadowed at least one but never > noticed. Yet. Not sure about that figure; any that are namespaced away in packages don't count (or rather, they count as just one, for the package itself). But yes, there are a lot. > I think it is a serious design flaw that the standard library and user code > co-exist in a single namespace. There are two concerns here. One is that if you create a "random.py", you can't yourself import the normal random module; and the other is the possibility that some unrelated application like Idle can be affected. I think the latter is far more serious than the former, which is basically equivalent to using "id" as a variable name and then finding you've shadowed a builtin (it affects only your current module, so it's pretty safe). But if I can create stuff that breaks Idle, that's a problem. And I think the solution to that is simply: never put your files onto the module search path, always just use the current directory. It might also be worth having some tools like Idle remove "" from sys.path, in case someone invokes it from a project directory, but that's an arguable point. (That's probably more useful for something like 2to3, where it's expected that you'll run it from a project directory. And maybe that already happens.) The only other way to separate them would be to do something like C's include paths - you have the user include path (which starts with the current directory) and the system include path (which doesn't), and then you can #include "local_file.h" and #include to get the one you want. In Python, that could be done as "import random from system", which would then look up sys.systempath instead of sys.path - but do we really need that functionality? ChrisA