> 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
I am a beginner at python programming and right now we have to write the text
to design a program that will make a histogram for Benford's law which says
that in a natural set of data 1 will appear more than 2 which will appear more
than 3 and so on. So given a set of data I want a list showing
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
I answered another question that says "Modify the guess_number program so
that the program's code is in a function called main(). Don't forget to call
main() so you can play the game." It seems to be working fine, but I would
like to have a second opinion if there was a better way to put it togeth
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
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
>>> import wx
>>> import s
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 \
Dave,
Thanks for the guidance. I followed your advice and learned the
following:
>>> import run
>>> print "run module:", run
run module:
The run.py file is there also. I can read but not understand what
run.py does. It may be something new in
Python 2.5. I have unistalled Python 2.4
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 -
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
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
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.basename(sys.argv[0])] +
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
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
It is very hard for me to understand why we need the following line?
if __name__ == "__main__":
___
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor
> 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
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
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
but why would I want to do this if __n
18 matches
Mail list logo