Syntax @Python(. [,]+) Arguments String The name of the module where the function resides. String The name of the Python function to call. String One or more arguments to pass to the Python function. Attribute values may be used as arguments by prefixing the attribute name with an ampersand ('&'). Description This FME function executes an arbitrary Python function, returning the result. It allows access to a complete procedural language with rich built-in primitives from within FME mapping files. Python procedures can be written to simplify tasks that are awkward to accomplish using standard mapping file syntax, and to allow users to extend FME to solve new problems. Python Function ~~~~~~~~~~~~~~~ The Python function that Python calls must, at the very minimum, accept a fmeobjects.FMEFeature object as its first parameter. Refer to the FME Objects API documentation for more information. Python functions called by @Python can, if desired, accept any number of optional arguments. Examples: # This function returns the contents of the test attribute. # The FME call looks like: # @Python(examples.noArgs) def noArgs(feature): return feature.getAttribute('test') # This function sets two integer attributes, and returns the sum # of two arguments. The FME call looks like: # @Python(examples.addAB,1,2) def addAB(feature,a,b): feature.setAttribute(int(a)) feature.setAttribute(int(b)) c = int(a) + int(b) return str(c) FME Objects Logging ~~~~~~~~~~~~~~~~~~~ It is possible to directly access the FME log file from a Python function via an FMELogfile object. Example: def logExample(feature, mymessage): import fmeobjects logger = fmeobjects.FMELogfile() logger.logMessageString(mymessage, fmeobjects.FME_INFORM) @Python( examples.logExample, "A message to log" ) Interpreter Configuration ~~~~~~~~~~~~~~~~~~~~~~~~~ The following directives can be used to configure the Python interpreter that FME loads. FME_PYTHON_PATH A path to add to Python's sys.path array that controls module loading. Wrap the path with quotation marks if it contains white space. FME_PYTHON_IMPORT The name of a Python module to import. Note: The module must reside in a directory referenced by Python's sys.path array.