0

This question is based on the assumption that you don't want to rename your modules and want to have # in their name.So how do you import these modules in Python? I tried using single/double inverted commas but still get a SyntaxError.

from "#Calc" import *

from '#Calc' import *

Please advise.

  • If you made these modules you should probably just rename them so they don't start with '#.' – ssp Jul 19 '20 at 18:18
  • 1
    Module name is a Python identifier. Python identifiers cannot contain a #. You cannot do what you want. – DYZ Jul 19 '20 at 18:19
  • Why do you name your modules like that in first place? https://www.python.org/dev/peps/pep-0008/#id40 – mx0 Jul 19 '20 at 18:24

1 Answers1

1

You could try importlib or calc = __import__('#Calc')

But the PEP 8 Style-Guide recommends not to use Upper-Case Letters or Symbols.

Modules should have short, all-lowercase names. Underscores can be used in the module name if it improves readability. Python packages should also have short, all-lowercase names, although the use of underscores is discouraged.

pce
  • 5,571
  • 2
  • 20
  • 25