Monday 9 September 2019

Do you need to use __name__=__main__ statement for running any script in python?







I just wanted to understand why you have you use the __name__='__main__'statement if we can run any python script even without using that statement.

For example, I can run the script below without using the if __name__='__main__' statement.



def hello():
print "hello"
return 1234

# And here is the function being used
print hello()

No comments:

Post a Comment

php - file_get_contents shows unexpected output while reading a file

I want to output an inline jpg image as a base64 encoded string, however when I do this : $contents = file_get_contents($filename); print &q...