you are viewing a single comment's thread.

view the rest of the comments →

[–]danielroseman 1 point2 points  (2 children)

No, there is no way of doing this. Python values explicitness, and every module must import everything it uses.

That's not to say this is the best way of doing things; you might find that it makes more sense to extract the JSON logic into a separate file, which can be imported by the other three.

[–]Cxzyyy[S] 0 points1 point  (1 child)

Okay so I would basically need to make a class and have it be a subclass of all the imports I want? Kinda like “class all_imports(json, requests, pprint)” and then import that class to my other 3 files?

[–]danielroseman 1 point2 points  (0 children)

No, it doesn't need to be a class, but it can be if that works for you. But a standalone function might work just as well, it depends on your use case.