rosuav at gmail.com
Thu Jul 5 23:52:17 EDT 2018
On Fri, Jul 6, 2018 at 12:56 PM, Sharan Basappa
<sharan.basappa at 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.
More information about the Python-list