greetings! i am beginner with python and confused what the if __name__ == __main__: main() means below is the script.--> #!/usr/bin/python def main(): f = open(sample.txt, w+) #writing some random stuff to file for i in range(10): f.write(this is a line %d\r\n % (i+1)) #close file when done f.close() if __name__ == __main__: main() #### i can call the function with main() only and it works thanks
Posted on: Sun, 26 Oct 2014 11:03:27 +0000