HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 2 months agoPython needs an actual default functionlemmy.mlimagemessage-square5linkfedilinkarrow-up10arrow-down10file-text
arrow-up10arrow-down1imagePython needs an actual default functionlemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 2 months agomessage-square5linkfedilinkfile-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-squareLucy :3@feddit.orglinkfedilinkarrow-up0·edit-22 months agoNever heard of def main(): pass if __name__ == '__main__': main() ?
minus-squaregrrgyle@slrpnk.netlinkfedilinkarrow-up0·2 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·2 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
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