Path: csiph.com!usenet.pasdenom.info!dedibox.gegeweb.org!gegeweb.eu!nntpfeed.proxad.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!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.023 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; 'name?': 0.09; 'subject:script': 0.09; 'python': 0.11; '2.7': 0.14; 'question.': 0.14; 'dumb.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'itself,': 0.16; 'subject:import': 0.16; 'obviously': 0.18; 'app': 0.19; 'import': 0.22; 'to:name:python- list@python.org': 0.22; 'looks': 0.24; 'least': 0.26; 'on,': 0.29; '(this': 0.29; "doesn't": 0.30; 'statement': 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'file': 0.32; 'skip:_ 10': 0.34; "can't": 0.35; 'something': 0.35; 'form.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'acceptable': 0.36; 'possible': 0.36; 'should': 0.36; 'application': 0.37; 'being': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'called': 0.40; 'tell': 0.60; 'back': 0.62; 'name': 0.63; 'answer.': 0.68; 'subject:All': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=0IVmxVGtT6Ps0FuDubXT/pc1Jx6odDjJoTbFrSMIhDw=; b=zSRaBzNb9hAQ53iUUAMuhJzaeEnyEypeUk4vJ6ge8OCFs7jFSUlx3dBjvSKfmEl+y1 cvFnsP/8x8ggA8sR9D7kQ8QSuyBkofBHZzqK0MVy0de+oBaJoFxzqRSMWnXRI03YRbWb KCjYvLcxaifD6c+arbgu5E9NqlI+UrgTmLNMhFOdMXf+7Wmj70nIBnjk8ta6ZDtzxol5 h7sHN+Jy1UOFPcu4vTxnK3ivrzrOjhXxFa/fy8kayDDAnd+4z8xCttyw7PY5Ol8csiAE B/edGaPst0hz+WC9/3T6DUnOsJVxdfbxZmn86Gbo9UheDwBS2GhocyQZy7W5nzjlF/JP if4w== MIME-Version: 1.0 X-Received: by 10.58.39.129 with SMTP id p1mr488046vek.69.1400680006304; Wed, 21 May 2014 06:46:46 -0700 (PDT) Date: Wed, 21 May 2014 23:46:46 +1000 Subject: All-numeric script names and import From: Chris Angelico To: "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: 1400680014 news.xs4all.nl 2894 [2001:888:2000:d::a6]:49517 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71854 If I have a file called 1.py, is there a way to import it? Obviously I can't import it as itself, but in theory, it should be possible to import something from it. I can manage it with __import__ (this is Python 2.7 I'm working on, at least for the moment), but not with the statement form. # from 1 import app as application # Doesn't work with a numeric name application = __import__("1").app Is there a way to tell Python that, syntactically, this thing that looks like a number is really a name? Or am I just being dumb? (Don't hold back on that last question. "Yes" is a perfectly acceptable answer. But please explain which of the several possibilities is the way I'm being dumb. Thanks!) ChrisA