On Sunday, 8 July 2018 11:52:39 UTC+5:30, Jim Lee wrote:
> On 07/07/18 21:21, Sharan Basappa wrote:
> > sorry. there was a copy paste error when i posted. I pasted test_2.py for both the files:
> > here are the files again. The issue remains.
> > [...]
> > output:
> > %run "D:/Projects/Initiatives/machine learning/programs/test_2_test.py"
> > 30
> [11:24 PM jlee at kerndev ~] $cat test_2.py
> x = 10
> y = 20
> c = x-y
> print c
> def func1():
> ??? return x+y
> [11:24 PM jlee at kerndev ~] $cat test_2_test.py
> import test_2
> x = test_2.func1()
> print x
> [11:24 PM jlee at kerndev ~] $python test_2_test.py
> [11:24 PM jlee at kerndev ~] $
> As you can see, the? code from the import is indeed executed by the
> python interpreter.
> I'm not familiar with the "%run" prefix in your command - some sort of
i think I figured out the issue. I am running this in Canopy. When I use Canopy Gui to run this, it appears that it loads the imported file only once. So, when I re-start canopy then everything goes fine the first time. When I use command prompt then it works all well.
PS: run is nothing but the front end command that Canopy uses to run Python in the background.