Importing some functions from a py file

Anthony Liu antonyliu2002 at yahoo.com
Tue Apr 19 23:05:48 EDT 2005


Hmm,thanks a lot.  I still don't quite get it.

So, instead of defining a main like

def main():
    do things here

I should do something like below in both modules?

if __name__ == "__main__":

    call the functions you defined here.


--- Michael Soulier <msoulier at gmail.com> wrote:
> On 4/19/05, Anthony Liu <antonyliu2002 at yahoo.com>
> wrote:
> > 
> > You are certainly right, because I don't know how
> to
> > protect the main functions.  Where do I put
> > 
> > if __name__ == '__main__': main()
> 
> I just glanced in the modules section of the python
> documentation and
> surprisingly this is not mentioned at all that I
> could see. I think
> that's an oversight.
> 
> See this example:
> 
>
http://diveintopython.org/getting_to_know_python/index.html
> 
> Mike
> 
> -- 
> Michael P. Soulier <msoulier at gmail.com>
> http://www.digitaltorque.ca
> http://opag.ca      python -c 'import this'
> Jabber: msoulier at digitaltorque.ca
> 

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Python-list mailing list