How to import module whose filename starts number
benjamin.kaplan at case.edu
Wed Dec 12 18:50:42 CET 2012
On Dec 12, 2012 9:47 AM, "Yong Hu" <yhu221300 at gmail.com> wrote:
> I have a few scripts whose file names start with numbers. For example,
> 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
I believe the restriction is that the module names must be valid
identifiers. You may still be able to import them using __import__ and then
assign the resulting module object to a valid name.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-list