On Mon, Mar 23, 2009 at 1:56 PM, <simon.wo...@gmail.com> wrote: > Hello, all. > > I don't suppose anyone has any idea why it seems to be impossible to > import any file which starts with a number? You get a syntax error, > whether the file exists or not.
Identifiers can't start with a number. http://docs.python.org/reference/lexical_analysis.html#identifiers > It's a bit annoying, as I have an enforced naming scheme. Any way > round it? You could import it like so: some_valid_identifer = __import__('1foo', globals(), locals()) http://docs.python.org/library/functions.html#__import__ But a far better solution is to fix your naming scheme—it's completely illogical to have a Python module naming scheme where the names aren't valid identifiers. -Miles -- http://mail.python.org/mailman/listinfo/python-list