adding more files .py to project


Hi there,

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 (with one or more functions defined inside).
Can I do that, and if so how?
I tried creating “” and in “” calling “from new import func” but that just threw a fit and didn’t compile…



Hi @AndiB 

you don’t need the “from”  :wink:


create a new file called with the following code where two new functions are defined:

def HelloPrint():
    print(“Hello Viper!”)    

def MySpecialFunction(a,b):
    print(“Parameter a is:”,a,“parameter b is:”,b)
<p>in the you write:</p><pre class=" CodeBlock">import functions<br>a=0<br>b=0<br>while True:<br>&nbsp; &nbsp; functions.HelloPrint()<br>&nbsp; &nbsp; a+=1<br>&nbsp; &nbsp; b+=10<br>&nbsp; &nbsp; functions.MySpecialFunction(a,b)<br>&nbsp; &nbsp; sleep(1000)


Thanks @floyd !