Should I create a file with all my module imports and then import * from that, or should I import the modules to each file I use?

StackOverflow https://stackoverflow.com/questions/22410923

문제

I have a project where I have to import a bunch of modules everytime I want to run some code. In order to avoid writing these over every time I create a new file, I created a sort of setup script that imports all of these, and then I just import * from that startup script. Is this stylistically ok? I could see why this would be confusing, when I reference modules/classes that can't be seen on import.... on the other hand, it saves time and space by not writing out the setup each time. What method should I do?

도움이 되었습니까?

해결책

For readability purposes it would be better to import each one in every file. So as you said it would make no sense with those files coming from no where. So for the purpose of readability it would be much, much better to import each one in every file. I could share some examples if you would like.

Cheers!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top