Make something with http://metapython.org/
? On Tue, Oct 4, 2011 at 3:21 AM, Aivar Annamaa <aivar.anna...@gmail.com> wrote: > Hi! > > 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__": ...` > > I found rejected PEP 299, but i thought that maybe there's something new > already. > > Here's why I want such a thing: > I'm teaching introductory programming course with Python. I've seen that > global variables attract beginners like honey attracts bees and this makes > teaching function parameters harder. When students learn functions, they > usually write their function definitions and function applications in the > same scope -- in top-level of the module (don't know the correct term for > it). This has the downside, that any variable introduced in top-level is > automatically visible in function definitions and I have hard time > convincing students not to use those variables in functions directly. > > I've been thinking that it might be better for teaching if all program code > would be in functions. This would make "Hello World" a bit more difficult, > but would help teaching the "real thing" ie. functions. > > best regards, > Aivar > > -- > http://mail.python.org/mailman/listinfo/python-list > > -- http://mail.python.org/mailman/listinfo/python-list