6 ms·
I don't get how this can be used anywhere except when you have 2 deployment targets which seems really limited. Also checking for environments is done weirdly,
by saco 6y ago
I don't get how this can be used anywhere except when you have 2 deployment targets which seems really limited.
Also checking for environments is done weirdly, why not use
if 'ENV' not in os.environ:
instead of
ENV = os.environ.get("ENV", None)
if ENV is None:
- karlicoss 6y agoMaybe just a habit, that way you don't have to repeat the literal "ENV" twice. In this case it doesn't matter much though. Also it's a bit better from the performance perspective (but not that it also matters in this case).
- bluntfang 6y ago>(but not that it also matters in this case) Then why mention it?
- salmo 6y agoThe practice is pretty common and a good reflex to have. In your version there would be a risk of a race condition if it was possible for the environment to change between the calls. Now, it’s not really an issue here with environment variables. But in general, doing assignment and then walking through the cases is safer.
- remram 6y agoI actually always use the second one but with just `if ENV`, to catch the case where the variable is set but empty, which happens a lot in practice with Docker&co.
- globular-toast 6y ago> I don't get how this can be used anywhere except when you have 2 deployment targets which seems really limited. Why do you say that? It looks like it can handle any number of environments to me.