Path: csiph.com!usenet.pasdenom.info!news.etla.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3.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.003 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'scripts': 0.03; 'assuming': 0.09; 'name?': 0.09; 'prefix': 0.09; 'subject:script': 0.09; 'python': 0.11; 'question.': 0.14; 'dumb.': 0.16; 'name)': 0.16; 'numbered': 0.16; 'pulling': 0.16; 'received:10.20.200': 0.16; 'received:209.225': 0.16; 'received:209.225.8': 0.16; 'received:charter.net': 0.16; 'script?': 0.16; "someone's": 0.16; 'subject:import': 0.16; 'alpha': 0.16; 'wrote:': 0.18; 'code.': 0.18; 'app': 0.19; 'module': 0.19; 'import': 0.22; 'otherwise,': 0.22; 'header:User-Agent:1': 0.23; 'looks': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'received:24': 0.27; 'chris': 0.29; 'am,': 0.29; 'character': 0.29; "doesn't": 0.30; "i'm": 0.30; 'run': 0.32; 'open': 0.33; 'received:10.20': 0.33; 'skip:_ 10': 0.34; 'but': 0.35; 'there': 0.35; 'really': 0.36; 'acceptable': 0.36; 'idle': 0.36; 'right?': 0.36; 'application': 0.37; 'received:209': 0.37; 'received:10': 0.37; 'being': 0.38; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'that,': 0.38; 'explain': 0.39; 'to:addr:python.org': 0.39; 'tell': 0.60; "you're": 0.61; 'back': 0.62; 'name': 0.63; 'our': 0.64; 'answer.': 0.68; 'click': 0.77; 'subject:All': 0.84; 'hand,': 0.93 X-Authority-Analysis: v=2.0 cv=F7QP7ddN c=1 sm=1 a=LkTX9YPXWU1lnSxlYEpgVg==:17 a=IuL6hPCtAYgA:10 a=9qL8LEEPaUMA:10 a=nDghuxUhq_wA:10 a=IkcTkHD0fZMA:10 a=pGLkceISAAAA:8 a=-Kw6OlLYRphbXTKl_-gA:9 a=QEXdDO2ut3YA:10 a=LkTX9YPXWU1lnSxlYEpgVg==:117 Date: Wed, 21 May 2014 09:24:30 -0500 From: Mark H Harris User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 MIME-Version: 1.0 Newsgroups: comp.lang.python To: python-list@python.org Subject: Re: All-numeric script names and import References: In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit 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: , Message-ID: Lines: 32 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1400684322 news.xs4all.nl 2913 [2001:888:2000:d::a6]:35223 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:71863 On 5/21/14 8:46 AM, Chris Angelico wrote: > # 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!) If you have a script that is self-programming (producing sequenced, numbered scripts 1.py 2.py 3.py) then why not just prefix an alpha character a1.py a2.py a3.py ? Otherwise, are you just pulling our chain? :) On the other hand, if you open IDLE and then open the 1.py module (yes, that's a dumb name) and then click run--> run module it will import and run... assuming 1.py contains some valid python code. Why must you have a numbered script? You're just pulling someone's chain, right? marcus