HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 7 months agoPython needs an actual default functionlemmy.mlimagemessage-square13fedilinkarrow-up14arrow-down10file-text
arrow-up14arrow-down1imagePython needs an actual default functionlemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 7 months agomessage-square13fedilinkfile-text
Also, do y’all call main() in the if block or do you just put the code you want to run in the if block?
minus-squarearschflugkoerper@feddit.orglinkfedilinkarrow-up0·7 months agoWhat kind of psychopath would put the code in the if block.
minus-squareHiddenLayer555@lemmy.mlOPlinkfedilinkEnglisharrow-up0·edit-27 months agoLooks at all the Python scripts in my bin folder that I wrote.
minus-squareLucy :3@feddit.orglinkfedilinkarrow-up0·edit-27 months agoNever heard of def main(): pass if __name__ == '__main__': main() ?
minus-squaregrrgyle@slrpnk.netlinkfedilinkarrow-up0·7 months agoI remember how weird this looked the first time I saw it and while I may now understand it, it still looks jank af
minus-squarebane_killgrind@slrpnk.netlinkfedilinkEnglisharrow-up1·7 months agoNow think about this, you have logic that doesn’t make sense when run directly, but you need it to be a library. You have multiple name=main statements in some of your functions
What kind of psychopath would put the code in the if block.
Looks at all the Python scripts in my bin folder that I wrote.
Never heard of
def main(): pass if __name__ == '__main__': main()?
I remember how weird this looked the first time I saw it and while I may now understand it, it still looks jank af
Now think about this, you have logic that doesn’t make sense when run directly, but you need it to be a library.
You have multiple name=main statements in some of your functions