4 ms·
Once I worked with a library, which when imported, started printing with a printer to paper. So yes, your Python program absolutely needs a main function and pl
by kissgyorgy 6y ago
Once I worked with a library, which when imported, started printing with a printer to paper. So yes, your Python program absolutely needs a main function and please no side effects at import time!
- KMag 6y agoHave you considered submitting the ballad of this unintentional malware to TheDailyWTF?
- tdeck 6y agoI don't see how these two are the same. No side effects at import time? Sure. But a program isn't meant to be imported, it's meant to be run, so there's no real expectation that a program should be importable without side effects.
- shoo 6y agothey're not the same, but they're both symptoms of the same underlying python behaviour: when you run a python file or import a python file, the interpreter immediately starts executing statements from the top of the file down.