<br><br><div class="gmail_quote">On Mon, Jan 19, 2009 at 2:39 PM, K-Dawg <span dir="ltr"><<a href="mailto:kdawg44@gmail.com">kdawg44@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Please forgive my beginner question. I have used python a little bit, mainly as a scripting language to perform specific administrative tasks. I have trying to learn to use it to develop applications but there are a few things I do not understand.<br>
<br>I come from more of a Java background. <br><br>I do no understand the underscore methods. __main__ - is this just the main method that is in the file that is actually executed? I also see __init__ a lot. What is that for? Is it like a constructor in Java or totally different?]</blockquote>
<div><br>Python doesn't have a main method. It's files are scripts and not programs. It's just like a shell script- everything is run. Unlike Java where everything has to be in a method in a class, you can have actions performed at the module level in Python. What you'll find is a lot of "if __name__ == '__main__'" conditionals. The name of the script that is run is always __main__, so you can use this to only run certain commands when the script is run directly as opposed to be imported by another module. <br>
<br>__init__ is the equivalent of a Java constructor.<br></div><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><br>
<br>Thanks for clearing it up. I am undertaking my first application development effort in python and anticipate discussing this with all of you a lot. :) Thanks for your support.<br><br>Kevin<br>
<br>--<br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
<br></blockquote></div><br>