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-uploader
might also mean the subtraction of uploader
from nmea
.
Since you can import a package anywhere in a python file, if you have defined the variables nmea
and uploader
in advance, the interpreter would get confused if a hyphen was allowed for identifier names.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With