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