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?

Ann Zen
  • 25,080
  • 7
  • 31
  • 51
Denis Ivanenko
  • 410
  • 7
  • 18
  • 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.

Ann Zen
  • 25,080
  • 7
  • 31
  • 51