ArcGIS Pro passes parameters to Python Toolbox (.pyt) Tool updateParameters, updateMessages and execute methods as a list. Changing this to a namedtuple by default would allow access by parameter name as well as by index.
Currently users can create a dictionary or a namedtuple themselves, e.g the way I do it is below, but I've also seen some fairly awkward attempts with globals and loops.
As a dict:
class Tool
etc...
def execute(self, parameters, messages):
parameters = {p.name: p for p in parameters}
# do something with parameters["some_name"]
As a namedtuple:
from collections import namedtuple
class Tool
etc...
def execute(self, parameters, messages):
parameters = namedtuple('Parameters', (p.name for p in parameters))(*parameters)
# do something with parameters[0] or parameters.some_name
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.