3 ms·
I have a question about a detail in the article: > But if we moved the log_to_network call out into the outer log_calls function, [...] this would no longer co
by konschubert 7y ago
I have a question about a detail in the article:
> But if we moved the log_to_network call out into the outer log_calls function, [...] this would no longer compile as a strict module.
My current understanding is that the log_calls method would NOT get executed during module load time!?!
Why would having a side effect in this function violate the intention of __strict__ ?
- scrollaway 7y ago> My current understanding is that the log_calls method would NOT get executed during module load time!?! That's incorrect. log_calls gets executed on import because it's a decorator, so equivalent to `hello_world = log_calls(hello_world)` at the top-level (which does also get executed). log_to_network in the _wrapped() definition doesn't get executed until hello_world gets called; but outside of the definition of _wrapped does get executed.
- konschubert 7y agoRight! I missed the fact that log_calls is used as a decorator further down.