4 ms·
You can use DI in Python too--it's an architectural pattern that can be used in any project regardless of language. I've never seen or used autoloading in Pyth
by saila 5y ago
You can use DI in Python too--it's an architectural pattern that can be used in any project regardless of language.
I've never seen or used autoloading in Python. What would the use case for that be? I guess it could be "convenient" to avoid imports? That seems like a bad idea to me and not very "Pythonic."
I'm not sure if this is relevant to your comment, but I've seen people abusing sys.path in Python projects instead of setting up a proper package and installing it.
Modern Python package/dependency managers like Poetry make this nicer/easier than the old school setup() approach and they also create lock files.
- pas 5y agoWe had problems with circular imports back then in a Flask based backend. Also we wanted configuration based loading. Local dev, testing, prod, on premise. Plus multi-tenancy meant that everything was very-very dynamic and additional layers of configurability were present based on the request. (So basically request scoped service injection was needed. Of course we did not do that, we just passed around a bunch of parameters in a "very Pythonic way".)
- saila 5y agoCircular imports often indicate an architectural issue. In any case, there are easy solutions in the rare cases where it's absolutely necessary, like putting one of the imports at the bottom of one of the modules or in a function. Regarding configuration based loading, that's something that's pretty common in Python webapps, and injecting capabilities/services per request seems like it would be pretty straightforward (and not anti-Pythonic either, depending on the implementation). I just don't see how Python makes this kind of thing more or less difficult than other languages.
- bshipp 5y agoCircular imports also are most common when you use 'from module import *'.