Importing function from another file.

16 views
Skip to first unread message

Ricardo Mc GRATH

unread,
Oct 6, 2016, 10:52:40 PM10/6/16
to PyScripter
Importing function from another file.
 
Hi, I'm  facing a weird with importing function from another file, it have strange behaviour when main code  execute method from another file.
The most strange point is if function are on the same main code it seems runs and works without nay problems, but if  set onto the main code function will be imported from an external file, when main code it execute it report the following error message;
TypeError: ............. () takes no arguments (2 given).
 
TKS.
 
main code example
 
 
from CalculosMatematicos import *
n1=int(input("Ingrese un numero"))
n2=int(input("Ingrese otro numero"))
CalculosMatematicos(n1,n2)
 
 
Importing file code called CalculosMatematicos.py
 
def CalculosMatematicos(a, b):
    if a > b:
    # then print this
        print(a, "es mayor")
    # si a is equal to b
    elif a == b:
    # print this
        print(a, "son iguales", b)
    # otherwise
    else:
        # print this
        print(b, "es mayor")
 

Andy Milne

unread,
Oct 6, 2016, 10:57:18 PM10/6/16
to pyscr...@googlegroups.com
Try naming the function something different than the name of the module.
--
You received this message because you are subscribed to the Google Groups "PyScripter" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pyscripter+unsubscribe@googlegroups.com.
To post to this group, send email to pyscr...@googlegroups.com.
Visit this group at https://groups.google.com/group/pyscripter.
For more options, visit https://groups.google.com/d/optout.


--
Sent from Gmail Mobile

Ricardo Mc GRATH

unread,
Oct 7, 2016, 12:36:01 AM10/7/16
to PyScripter
 
Thanks for your reply, awesome it solve!!
Reply all
Reply to author
Forward
0 new messages