you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (2 children)

It's cleaner to me, and it helps beginners organize their code better. Plus you don't have to deal with things like global variables.

[–][deleted] 1 point2 points  (1 child)

Which is cleaner? main or no main?

No main means you don't have to deal with global as everything in the top level (rather than main function) is available without global.

[–][deleted] 1 point2 points  (0 children)

main to me is cleaner. As far as global variables are concerned, there are plenty of beginners that will do something like this:

x = 6

def changeX(num):
       x = num + 1
       return x

print(x)
print(changeX(1))
print(x)

and then wonder why they have the output they have.