Is there a way to reference parameters in an ArcGIS Pro Python Toolbox by name, instead of by numeric index / positional argument?
I built a data entry tool in a Python Toolbox that has over 100 parameters. If I need to add, remove, or reorder any of these, it becomes a massive undertaking to edit every entry in updateParameters(), updateMessages(), and execute().
Update: I've deleted my attempt, because it's bad, and only user2856's accepted answer should be on record.
Best Answer
Don't use a
global
. Just create a dictionary whenever you need to access parameters, e.g. inupdateParameters
,updateMessages
,execute
, etc:e.g.
Another option is to create a
namedtuple
(could be a good ArcGIS Pro Idea) so you can access by index (backwards compatibility) as well as name.There's an ArcGIS Idea to change the
parameters
type from a list to aNamedTuple
that you can support.