All-numeric script names and import

Rustom Mody rustompmody at gmail.com
Thu May 22 22:08:09 EDT 2014


On Wednesday, May 21, 2014 7:16:46 PM UTC+5:30, Chris Angelico wrote:
> 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.


$ cat ا.py
x = 1
def foo(x): print("Hi %s!!" % x)



$ python3
Python 3.3.5 (default, Mar 22 2014, 13:24:53) 
[GCC 4.8.2] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import ا
>>> ا.foo('Chris')
Hi Chris!!
>>> ا.x
1



More information about the Python-list mailing list