Sorry for hijacking Alec's response but I didn't see the OP.

> Aivar Annamaa <aivar.anna...@gmail.com> wrote:
> > I'm looking for a trick or hidden feature to make Python 3 automatically
> > call a "main" function but without programmers writing `if __name__ ==
> > "__main__": ...`

One direct way is to call it from the command line:

   python -c "import mymodule; mymodule.main()"

After your students have had to use that verbose form for a while,
they'll be more than happy to add the boilerplate themselves to the
end of their modules :)
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to