![](https://secure.gravatar.com/avatar/59f6521846b85e7a81f335670f15c9c9.jpg?s=120&d=mm&r=g)
25 Nov
2013
25 Nov
'13
10:25 p.m.
2013/11/24 Guido van Rossum <guido@python.org>
if is_main(): <do your main code>
How about going the other way around? if imported(): break <do your main code> Most of the time, people put the main stuff at the end of the script, so this check can serve as a seperator, equivalent to what is sometimes marked with '***********************' - snip the script here. Of course, it is still possible to do if not imported(): main() I think it is at least as obvious as is_main(), and even more so for those without a C-like background. (Personally I'd prefer an `imported` magic variable but I guess that's out of question). Elazar