I’m using python 2.6 and get the following when importing a module:
File "./test-nmea-uploader.py", line 11
import nmea-uploader as sut
^
SyntaxError: invalid syntax
Why is that so? The python style guide seems to hold no mention about using hyphens in names, although it suggest the use of underscores.
Alan
According to http://docs.python.org/reference/lexical_analysis.html#identifiers, any identifier must start with a lowercase/uppercase letter or an underscore and contain lowercase/uppercase letters, numbers or an underscore.
Package names are identifiers, so they are bound to the same rules.
In addition,
nmea-uploadermight also mean the subtraction ofuploaderfromnmea.Since you can import a package anywhere in a python file, if you have defined the variables
nmeaanduploaderin advance, the interpreter would get confused if a hyphen was allowed for identifier names.