Re: [Tutor] Main function

2014-05-20 Thread Danny Yoo
> Since I'm new to python and don't really know how to write programs yet, my > first question would be what exactly is the main function, because we did a > similar assignment before this one that included it, and I'm not sure what > exactly it does. When you write a program, you write a collect

Re: [Tutor] Main Function

2011-06-20 Thread Christopher King
Looks all good except for this: while guess == the_number: Since you break out at the end, an if statement would be a more logical choice. and also: if tries == 4: print("\nYou fail!") input("\n\nPress the enter key to exit.") break you don't need to break because t

Re: [Tutor] Main program confusion

2007-02-19 Thread Luke Paireepinart
Hazlett, Les wrote: > > Thanks Kent, > > Yes, there is a run.py in the demo folder. I is the one that runs and > not the one in the Python25 lib. > > So, I tried to see if I could find it if I previously imported > everything that the code imports. It didn’t – see below: > > IDLE 1.2 > > >>> impo

Re: [Tutor] Main program confusion

2007-02-19 Thread Kent Johnson
Hazlett, Les wrote: > Dave, > > Thanks for the guidance. I followed your advice and learned the following: > >> >> import run > >> >> print "run module:", run > > run module: I don't think that is the correct run.py. > Luke, > > I found this mystery main program in the extensive demos in \

Re: [Tutor] Main program confusion

2007-02-19 Thread [EMAIL PROTECTED]
It's wxpython demo's code. It's necessary to have the run.py in the same path, to make it run, and usually also some other files. -- Tom, http://www.vscripts.net > I've never heard of this module. Where did this code come from? ___ Tutor maillist -

Re: [Tutor] Main program confusion

2007-02-19 Thread Luke Paireepinart
Hazlett, Les wrote: > > Hello, > > I am trying to understand some sample code that includes the following > for a main program: > > def runTest(frame, nb, log): > > win = TestPanel(nb, log) > > return win > > if __name__ == '__main__': > > import sys,os > > import run > > run.main(['', os.path.bas

Re: [Tutor] Main program confusion

2007-02-19 Thread Dave Kuhlman
On Mon, Feb 19, 2007 at 10:15:08AM -0600, Hazlett, Les wrote: > > if __name__ == '__main__': > import sys,os > import run > run.main(['', os.path.basename(sys.argv[0])] + sys.argv[1:]) > [snip] > if__name__=='__main__' only runs when this program file is executed. > > But, I can't

Re: [Tutor] main

2005-11-05 Thread bob
At 03:39 PM 11/5/2005, Shi Mu wrote: >It is very hard for me to understand why we need the following line? >if __name__ == "__main__": We don't need it. Often we code a module for importing into another module. But sometimes we also want to run the module independently as a Python program, perha

Re: [Tutor] main

2005-11-05 Thread Danny Yoo
On Sat, 5 Nov 2005, Shi Mu wrote: > It is very hard for me to understand why we need the following line? if > __name__ == "__main__": Hi Shi Mu, It's tied to the concept of modules. Have you learned about modules yet? Python programs can be split into several modular pieces, and these "modu

Re: [Tutor] main()

2005-05-21 Thread Alan G
> able to glean some information. When you call a script __name__ is set > to the "Name" of the script called. example: python Hope.py > __name__ = Hope Actually no. When you *import* a file its name is set to the file name(or more acurately the module name) When you run a file from the command

Re: [Tutor] main()

2005-05-21 Thread Roel Schroeven
Servando Garcia wrote: > > if __name__ == '__main__': > > what is the meaning and importance of this code line. I have been > able to glean some information. When you call a script __name__ is set > to the "Name" of the script called. example: python Hope.py > __name__ = Hope Whe