Re:Ask HN: Good Python projects to read for modern Python?
by willm on Monday December 27, 2021 @05:35PM
(#29707677)
That is not the case. The code within that block will not be in the namespace if that file is imported. Contrary to your example which will have the main function in the module namespace.
[ Parent
| on HN ]
Re:Ask HN: Good Python projects to read for modern Python?
by FreakLegion on Tuesday December 28, 2021 @01:56AM
(#29711212)
> "if that file is imported"
Static analysis doesn't care. The script can be executed directly, so it has to be treated as if it will be. The fact that the code behaves differently between prod and dev use is a smell, not a selling point.
I'm saying this in the context of writing modern Python with modern tools. In that context it's a poor practice.