Bart Willems [EMAIL PROTECTED] wrote:
gtb wrote:
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
This might be obvious, but no one else mentioned it: the Python
interpreter cannot execute code that it hasn't compiled yet, which is
why the if
On Sun, 29 Apr 2007 07:32:44 -0400, Bart Willems wrote:
gtb wrote:
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
This might be obvious, but no one else mentioned it: the Python
interpreter cannot execute code that it hasn't compiled yet, which is
gtb wrote:
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
This might be obvious, but no one else mentioned it: the Python
interpreter cannot execute code that it hasn't compiled yet, which is
why the if __name__ ... code is always at the end of the
On Apr 29, 9:32 pm, Bart Willems [EMAIL PROTECTED] wrote:
gtb wrote:
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
This might be obvious, but no one else mentioned it: the Python
interpreter cannot execute code that it hasn't compiled yet, which
alisonken1 wrote:
[if __name__ == __main__]
These are samples to give the programmer an idea of how the code
is supposed to work.
No, this belongs into comments or docs. The contents of this block
are often used for testing or debugging, or for normally executable
code if it makes sense to
The lines
if __name__ == 'main':
someClass().fn()
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
The last line of the sample below has a string parameter. When I
mimicked this I got an error stating that the class constructor did
not take an arg
The lines
if __name__ == 'main':
someClass().fn()
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
Python doesn't generate .class files, and the example you mean is
probably more like
if __name__ == '__main__':
.whatever
On Apr 27, 2:08 pm, gtb [EMAIL PROTECTED] wrote:
The lines
if __name__ == 'main':
someClass().fn()
appear at the end of many examples I see. Is this to cause a .class
file to be generated?
These are samples to give the programmer an idea of how the code is
supposed to work. If you cut
Sorry for the wrong implication. I should have said I 'mimicked the
style'.
No, not used to Java at all, and obviously not versed in python either
(do I get points for tcl?). Maxq generates jython scripts and when I
saw the .class files I assumed it was the work of the python compiler
as what is
Hi,
I often see the following 'if' construct in python code. What does
this idiom accomplish? What happens if this is not main? How did I get
here if it is not main?
Thanks,
gtb
==
if __name__ == 'main':
myQuest('myQuest').Run()
--
http
gtb wrote:
I often see the following 'if' construct in python code. What does
this idiom accomplish? What happens if this is not main? How did I get
here if it is not main?
...
if __name__ == 'main':
myQuest('myQuest').Run()
This idiom is for executing the code if you're running
here if it is not main?
By importing the file.
if __name__ == 'main':
myQuest('myQuest').Run()
--
Grant Edwards grante Yow! Thank god!!... It's
at HENNY YOUNGMAN!!
visi.com
On Mar 20, 11:49 am, gtb [EMAIL PROTECTED] wrote:
Hi,
I often see the following 'if' construct in python code. What does
this idiom accomplish? What happens if this is not main? How did I get
here if it is not main?
A quick example demonstrates the usage:
C:\codetype temp.py
print Module
On Mar 20, 12:13 pm, Patrick Down [EMAIL PROTECTED] wrote:
On Mar 20, 11:49 am, gtb [EMAIL PROTECTED] wrote:
Hi,
I often see the following 'if' construct in python code. What does
this idiom accomplish? What happens if this is not main? How did I get
here if it is not main?
A quick
14 matches
Mail list logo