woodenzen / zkdb

Zettelkasten Stats Dashboard
4 stars 2 forks source link

The file can now run standalone or be used to import TheArchive class #5

Closed flengyel closed 3 years ago

flengyel commented 3 years ago

Every module has a __name__. If that string variable is "main" it means the module is running standalone. This enables the original test code to run only when the module runs standalone; otherwise the test code will be prevented from running when the module is used to import classes. So you get both. It's a useful and standard technique.

flengyel commented 3 years ago

This explains what the if statement does:

https://stackoverflow.com/questions/419163/what-does-if-name-main-do