On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa
<sharan.basa...@gmail.com> wrote:
> Please let me know if the following understanding of mine is correct.
> I need to put the program code in a separate file and organize every 
> executable code in some form of function. If any code exists outside of 
> function then it is not executable by importing.
>

Kinda. It's actually the other way around: if any code exists outside
of functions, it will be executed immediately when you import. So
you're correct in that it would be hard (maybe impossible) to
unit-test that; and yes, the normal way to do it is to put all your
important code into functions.

ChrisA
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to