I love the idea of __imported__ but would like to suggest taking it even further - why not, rather that a bool for __imported__, have the value of it be either None (if __name__ == "__main__") or the __name__ of the module that it is being imported from. This could potentially be useful in trying to resolve circular imports, imports via importlib or exec, etc. The code need would be slightly more complex needing to check the current call stack at the time of import but I don't think that it would be too much overhead.
Excellent redirect of original proposal: +10
From: André Roberge <email@example.com>
As a goal of making it even more obvious what the (new) idiom mans, I would suggest a variable named __imported__ with the opposite value to what is proposed.
if not __imported__:
would behave the same as the proposed