HiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 12 days agoPython needs an actual default functionlemmy.mlimagemessage-square104linkfedilinkarrow-up11file-text
arrow-up11imagePython needs an actual default functionlemmy.mlHiddenLayer555@lemmy.ml to Programmer Humor@programming.devEnglish · 12 days agomessage-square104linkfedilinkfile-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-squareHiddenLayer555@lemmy.mlOPlinkfedilinkEnglisharrow-up0·edit-212 days agoLooks at all the Python scripts in my bin folder that I wrote.
minus-squareAnomalocaris@lemm.eelinkfedilinkarrow-up0·12 days agocustom bin folders are a realm no God dares to tread
minus-squareSubArcticTundra@lemmy.mllinkfedilinkarrow-up0·edit-212 days agoI can and I do *trollface*
minus-squareLucy :3@feddit.orglinkfedilinkarrow-up0·edit-212 days agoNever heard of def main(): pass if __name__ == '__main__': main() ?
minus-squareHiddenLayer555@lemmy.mlOPlinkfedilinkEnglisharrow-up0·edit-212 days agoHeard of it, was too lazy to do it that way. To be fair I now do it that way, but not when I was learning Python.
minus-squareLucy :3@feddit.orglinkfedilinkarrow-up0·12 days agoNot having tons of code in one if statement, but in a function.
minus-squareIronKrill@lemmy.calinkfedilinkarrow-up0·12 days agoAnd scope. Variables declared in the if can be read everywhere, variables declared in the function are limited to that function.
Looks at all the Python scripts in my bin folder that I wrote.
custom bin folders are a realm no God dares to tread
I can and I do
*trollface*
Never heard of
def main(): pass if __name__ == '__main__': main()
?
Heard of it, was too lazy to do it that way.
To be fair I now do it that way, but not when I was learning Python.
What is the point of this?
Not having tons of code in one if statement, but in a function.
And scope. Variables declared in the if can be read everywhere, variables declared in the function are limited to that function.