# define a function to write hello world # python does not have scope delimiters to indicate where code belongs # -- use indentation to do this def main(): print "hello world!" # this alone won't do anything. need to call the main() function # if this module (file of py code) is loaded and interpreter assigned __name__ property the # value of __main__. means py program is executed as a main program! so can be called from # command line # distinguishes between when a python code is being executed as part of a library or as # a program. when it's a program, this will get called. if __name__ == "__main__": main() print "me too"
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question