Python String Custom Functions

5 posts / 0 new
Last post
Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57
Python String Custom Functions

I just put together a package of python scripts for the IDEA Equation Editor. There are 18 functions that add on what you can do to a character string. You can find the package here:

http://ideascripting.com/IDEA_Lab/python-string-custom-functions

kritesh anand
Offline
Joined: 02/22/2019 - 06:18

User defined function. In&nbsp;Python, a&nbsp;user-defined function's&nbsp;declaration begins with the keyword def and followed by the&nbsp;function&nbsp;name. The&nbsp;function&nbsp;may take arguments(s) as input within the opening and closing parentheses, just after the function&nbsp;name followed by a colon.</p>
<p>If you want to enahnce your learning on Python then you <a href="http://pythonandmltrainingcourses.com/courses/best-python-training-in-no...">best python training classes in Noida</a>

TMC
Offline
Joined: 10/20/2016 - 09:43

Hi Brian,
 
Access denied
 

You are not authorized to access this page.
 
:-S
 
I cannot get my custom python function to work How do I do this properly: pseudocode:
import fuzz from fuzzywuzzy
def CompareTwoFields(field1, field2):
           return fuzz.ratio(field1, field2)

Humphrey
Offline
Joined: 10/13/2020 - 09:34

Hello Brian,
Access to this page is denied.

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Hi Humphrey,

The pages have been taken down as it is now part of the IDEA Lab which is part of IDEA.

The problem with your return is that it has to return a string, so you have to cast your return value to string before IDEA will read it.

Here is an example:


#
# Usage example: appending a virtual character field to the Sample-Detailed Sales database.
# Equation example: @Python("GetPercent", SALES_TAX, SALES_BEF_TAX)
#
def GetPercent(numerator, denominator):
	if(denominator == 0): 
		return "N/A"
	return "{0:.2f} %".format(numerator/denominator*100)