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.004 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'string': 0.09; '22,': 0.09; 'attributes': 0.09; 'contexts': 0.09; 'happen,': 0.09; 'literal': 0.09; 'subject:script': 0.09; 'yeah,': 0.09; 'cc:addr :python-list': 0.11; 'dots': 0.16; 'expects': 0.16; 'fiddle': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'imported.': 0.16; 'integer,': 0.16; 'name).': 0.16; 'subject:import': 0.16; '(you': 0.16; 'wrote:': 0.18; 'thu,': 0.19; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'pass': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'am,': 0.29; 'document.': 0.30; 'message- id:@mail.gmail.com': 0.30; 'way?': 0.31; 'file': 0.32; 'probably': 0.32; 'skip:_ 10': 0.34; 'could': 0.34; "can't": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'issue': 0.38; "couldn't": 0.39; 'called': 0.40; 'even': 0.60; 'dave': 0.60; 'most': 0.60; 'name': 0.63; 'different': 0.65; "it'd": 0.84; 'subject:All': 0.84; 'angel': 0.91; 'error;': 0.91; 'to:none': 0.92 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=csTlFi5BcKKk4Yv/u/AFu2A7o90a2ViEA/WM4T1793Q=; b=Oonfwdvs7TO3DPcpJvgz/uI0hPftLDrxfgEe/NtyEpDpMcSNTXRvZ0p1ZYkgHmuTc8 EV0zvbqYeBma+a2km/pwbMfNIFb+5peB+LEtJtV8rRKp52zsUx7oPerilJIKDiAkx8B/ maVMLQpTKNWNuOxQkn7qiGypfzF7bxd8vh1ZxQnWRKmGtm7G+90GJzJFPeYRYaJA9ipF U6t/iWPpNWImNRxbeUPPr5m6Qw9Jp5mQ4K/JbPeU4J1OK0Iur4wZ4jedLjgyN+yXNRej jhy1K2/9sH2uQR0dYgwV+XNIVmY+GzJMa6Ja8B0Yhdr019RbRQFPaNHFQ5O50Tpdlltb wj5w== MIME-Version: 1.0 X-Received: by 10.220.133.197 with SMTP id g5mr10169059vct.20.1400683419107; Wed, 21 May 2014 07:43:39 -0700 (PDT) In-Reply-To: References: Date: Thu, 22 May 2014 00:43:39 +1000 Subject: Re: All-numeric script names and import 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: 17 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1400683422 news.xs4all.nl 2845 [2001:888:2000:d::a6]:53710 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71860 On Thu, May 22, 2014 at 12:32 AM, Dave Angel wrote: > I don't think there's any question of dumbhood, but the answer > should be found in the formal grammar document. Yeah, I figured it'd be an issue of the grammar. It expects 1 to mean an integer, not a name - which in most contexts is correct (you can't go "1 = 2" because 1 isn't a name). In some contexts you can force a different interpretation, so for instance you can look at attributes of an integer literal as (1).real even though 1.real is an error; but I couldn't find a way to fiddle this one. And the only way I could find to pass a string was to use __import__(). So is that the only way? Same thing would happen, I guess, if you have dots in the file name. A file called "foo.bar.py" probably can't be imported. ChrisA