placid wrote: > Hi all, > > How do i import a module that has an hypen/dash (-) in its name ? I get > a SytaxError exception
You can use function __import__. >>> print open("-test.py").read() def fun2(): return "Hello from -test !" >>> import -test File "<stdin>", line 1 import -test ^ SyntaxError: invalid syntax >>> __import__("-test", globals(), locals(), []) <module '-test' from '-test.pyc'> But here is another problem: >>> -test.fun2() Traceback (most recent call last): File "<stdin>", line 1, in ? NameError: name 'test' is not defined >>> import sys >>> sys.modules["-test"].fun2() 'Hello from -test !' Regards, Rob -- http://mail.python.org/mailman/listinfo/python-list