I’ve been playing with the Viper IDE and a Photon, so far with nice results.
However, now that I want to go a bit further I was wondering if it’s in any way possible to import additional .py files?
So, for example let’s say I write some lengthy code to read a particular sensor and want to store that in sensor.py (with one or more functions defined inside).
Can I do that, and if so how?
I tried creating “new.py” and in “main.py” calling “from new import func” but that just threw a fit and didn’t compile…
you don’t need the “from”
create a new file called functions.py with the following code where two new functions are defined:
print(“Parameter a is:”,a,“parameter b is:”,b)
<p>in the main.py you write:</p><pre class=" CodeBlock">import functions<br>a=0<br>b=0<br>while True:<br> functions.HelloPrint()<br> a+=1<br> b+=10<br> functions.MySpecialFunction(a,b)<br> sleep(1000)