Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!news.stack.nl!aioe.org!.POSTED!not-for-mail From: Mark H Harris Newsgroups: comp.lang.python Subject: Re: All-numeric script names and import Date: Wed, 21 May 2014 09:24:30 -0500 Organization: Aioe.org NNTP Server Lines: 32 Message-ID: <537CB71E.5060506@gmail.com> References: NNTP-Posting-Host: eSF12mcVRIwL+eMIMJ03mA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:24.0) Gecko/20100101 Thunderbird/24.5.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.python:71856 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