[Tutor] Using import
Felipe Melo
felipe146 at hotmail.com
Fri May 2 18:40:20 CEST 2014
Hello,
I'm starting with Python and I'm trying to work with "import" but I'm having a problem.
I have the file c.py (that works when executed) with a function performing a multiplication:
def mult(a,x): resul=a*x return(resul)print 'test print'ent1=2ent3=3dedo=mult(ent1,ent3)print 'result: ',dedo
and I have the file b.py that calls c.py but should only print a sentence, without use the function in c.py (I tried to use the code without the comment part but got the problem, my goal is to use b.py with the commented part being part of the code):
import c
ent1=2ent2=7print 'testing b.py without any operation'
#saida=c.mult(ent1,ent2)#print 'the output is:',saida
My problem is when I execute b.py, it executes c.py before b.py:
$ python b.py test printresult: 6testing b.py without any operation
How should I work with this? What I want is use the function defined in c.py inside b.py
Regards,Felipe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140502/624980f6/attachment.html>
More information about the Tutor
mailing list