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, whi
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
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 ye
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
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
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 v
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
> 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 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
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:\code>type temp.py
prin
On 2007-03-20, gtb <[EMAIL PROTECTED]> wrote:
> I often see the following 'if' construct in python code. What does
> this idiom accomplish?
It checks to see if the file is being run as the "main"
program, and does something if that is so.
> What happens if this is not main?
Nothing.
> How did
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 t
12 matches
Mail list logo