On Mon, Oct 3, 2011 at 1:14 PM, Dave Angel <da...@ieee.org> wrote: > Is it explaining the if statement that's the problem? If so, you could have > them do an unconditional main(sys.argv) at the bottom of their file, and not > bother putting an if statement in front of it. Then when you get to > user-written modules, you could introduce the if __name__ and explain its > need.
It's not a good idea to teach bad habits they'll just have to unlearn later on. Especially since they might not be paying attention when you talk about if __name__ and how to do it right. I would suggest giving them the whole if __name__ block as boilerplate and telling them they're not allowed to alter it. Then in a later class, explain its purpose. -- http://mail.python.org/mailman/listinfo/python-list