News for hackers. Stuff that matters.
Re:An exploration of why Python doesn't require a 'main' fun... by kissgyorgy on Tuesday July 21, 2020 @02:13PM (#23909274)
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!
Re:An exploration of why Python doesn't require a 'main' fun... by KMag on Tuesday July 21, 2020 @03:03PM (#23909797)
Have you considered submitting the ballad of this unintentional malware to TheDailyWTF?
Re:An exploration of why Python doesn't require a 'main' fun... by tdeck on Tuesday July 21, 2020 @05:09PM (#23911029)
I 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.
Re:An exploration of why Python doesn't require a 'main' fun... by shoo on Tuesday July 21, 2020 @06:28PM (#23911661)
they'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.