All-numeric script names and import

Mark H Harris harrismh777 at gmail.com
Wed May 21 10:24:30 EDT 2014


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



More information about the Python-list mailing list