On 12/12/2012 12:42 PM, Yong Hu wrote:
> I have a few scripts whose file names start with numbers. For example, 
> 01_step1.py, 02_step2.py
>
> I tried to import them in another script by "import 01_step1" or "from 
> 01_step1 import *". Both failed, saying "SyntaxError: invalid syntax"
>
> Is there anyway to import those files? The file name must start with 
> characters?

A module name is like any other symbol in Python.  It must start with a
letter (one of a hundred thousand or so), and have only letters or
digits within it.  Plus underscore, and maybe a couple more special
characters.

mv would be your best bet.  But if you HAVE to have a strange name, try
using the __import__() function.



-- 

DaveA

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to