1

I need to support Python code, which was written by another person and it contains imports, that are placed not at the top of the module. And I'm a bit afraid to break something, as project is quite complex.

So when it can be good to use imports not on the top of the file?

Red
  • 26,798
  • 7
  • 36
  • 58
Denys Ivanenko
  • 388
  • 7
  • 21
  • 2
    Might be useful: [Should import statements always be at the top of a module?](https://stackoverflow.com/questions/128478/should-import-statements-always-be-at-the-top-of-a-module) – Sercan Jul 06 '20 at 22:44

1 Answers1

1

If you have a python program that has different paths, and only one of the paths use a specific module, you can import the module in that specific path. So you won't be importing many module you won't use.

Red
  • 26,798
  • 7
  • 36
  • 58