0

When I'm importing packages/custom modules the import statement only accepts single word input. I looked up the Packages info in the Python Docs and the example there only has one word imports. Are multi-word imports possible?

This works:

import Histogram

But this doesn't:

import File existence check
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61

2 Answers2

1

You could use the builtin __import__, but it'd probably be better to not have spaces in the name.

package = __import__("Name with spaces")
duckboycool
  • 2,425
  • 2
  • 8
  • 23
0

Don't use space when you want to name something. Use Camelcase like FileExistenceCheck or go with File_existence_check. I don't know if it would work just seen from the syntax but anyway you should not do it!

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
RhYLow
  • 1
  • 1