django-redshift icon indicating copy to clipboard operation
django-redshift copied to clipboard

Modules with dashes in their names can't be imported normally

Open thatjpk opened this issue 11 years ago • 0 comments

Installing django-redshift using pip install django-redshift puts a directory in site-packages named "django-redshift". To import it, one would use import django-redshift, but the dash there is a syntax error. Workarounds for this include:

  • Putting a dash-less symlink in site-packages to django-redshift allows the module to be imported using the name of the symlink.
  • Doing something like django_redshift = __import__("django-redshift") instead of a regular import statement.

Both of which are kind of gross. The pythonic solution is apparently to rename the module (see http://stackoverflow.com/questions/761519/is-it-ok-to-use-dashes-in-python-files-when-trying-to-import-them).

thatjpk avatar May 27 '14 19:05 thatjpk