Python: passing parameters by name

Hi, I was wondering how to implement this in python. Suppose, for example, you have a function with two parameters and both are printed to the console

def myFunc(varA, varB):
    print 'varA=', varA
    print 'varB=', varB

I saw libraries (pymel is the one that comes to mind), where it allows you to specify a parameter that you analyze data also by name in random order. eg

myFunc(varB=12, varA = 'Tom')

I'm not sure what I am missing, as this does not work when I try to declare my own functions inside or outside the maya environment.

Any tips would be great, thank you in the forefront.

+5
source share
1 answer

Python. , - (, , ..).

>>> def func(foo, bar):
...   print foo, bar
... 
>>> func(bar='quux', foo=42)
42 quux
+11

All Articles