Custom Function error in import file in Python interactive environment

Source: Internet
Author: User

Today, when I was learning a python custom function, I encountered a problem: I use the notepad++ Editor custom function, in the interactive environment using the From FileName Import function name Imports, has been an error, check several times, has been reported this error:

The code is as follows:

#-*-coding:utf-8-*-#Custom Function def function name (parameter 1, parameter 2 ...) : Then write the function body in the indent body, return the value with return#custom Seek absolute value function#def my_abs (x):    #If the argument type is not int or float, the type error exception is thrown#if not isinstance (x, (Int,float)):#raise TypeError (' bad operand type ')#if x > 0:#return x#Else:#Return-x#Print (My_abs ( -2))ImportMathdefquadratic (a,b,c):if( notIsinstance (A, (int,float)))or( notIsinstance (b, (int,float)))or( notIsinstance (c, (Int,float))):RaiseTypeError ("Bad operand type") x= (b*b)/(4*a*a)-c/a Y= Math.sqrt (x)-b/(a)returnY

Finally found that the import of the time did not generate the compilation file, the previous compilation files are deleted and then re-import it.

Custom Function error in import file in Python interactive environment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.