▲ 733 ▼ Python needs an actual default function (lemmy.ml) submitted 1 year ago by HiddenLayer555@lemmy.ml to c/programmer_humor@programming.dev 160 comments fedilink hide all child comments 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?
[–] firelizzard@programming.dev 4 points 1 year ago (1 child) What is the point of this? permalink fedilink source parent hideshow 2 child comments replies: [–] 30p87@feddit.org 7 points 1 year ago (2 children) Not having tons of code in one if statement, but in a function. permalink fedilink source parent hideshow 4 child comments replies: [–] IronKrill@lemmy.ca 12 points 1 year ago And scope. Variables declared in the if can be read everywhere, variables declared in the function are limited to that function. permalink fedilink source parent [–] firelizzard@programming.dev 2 points 1 year ago (1 child) I thought you were saying to literally use def main(): pass, that’s why I was confused permalink fedilink source parent hideshow 2 child comments replies: [–] 30p87@feddit.org 1 point 1 year ago Oh, no, that's just the usual placeholder. Though, ... would also be valid iirc, and would fit better as a "TODO" placeholder permalink fedilink source parent
[–] 30p87@feddit.org 7 points 1 year ago (2 children) Not having tons of code in one if statement, but in a function. permalink fedilink source parent hideshow 4 child comments replies: [–] IronKrill@lemmy.ca 12 points 1 year ago And scope. Variables declared in the if can be read everywhere, variables declared in the function are limited to that function. permalink fedilink source parent [–] firelizzard@programming.dev 2 points 1 year ago (1 child) I thought you were saying to literally use def main(): pass, that’s why I was confused permalink fedilink source parent hideshow 2 child comments replies: [–] 30p87@feddit.org 1 point 1 year ago Oh, no, that's just the usual placeholder. Though, ... would also be valid iirc, and would fit better as a "TODO" placeholder permalink fedilink source parent
[–] IronKrill@lemmy.ca 12 points 1 year ago And scope. Variables declared in the if can be read everywhere, variables declared in the function are limited to that function. permalink fedilink source parent
[–] firelizzard@programming.dev 2 points 1 year ago (1 child) I thought you were saying to literally use def main(): pass, that’s why I was confused permalink fedilink source parent hideshow 2 child comments replies: [–] 30p87@feddit.org 1 point 1 year ago Oh, no, that's just the usual placeholder. Though, ... would also be valid iirc, and would fit better as a "TODO" placeholder permalink fedilink source parent
[–] 30p87@feddit.org 1 point 1 year ago Oh, no, that's just the usual placeholder. Though, ... would also be valid iirc, and would fit better as a "TODO" placeholder permalink fedilink source parent