Look at this site
http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/
I would say looking at more examples will help.
The way I understand it - if function accepts *args then you can pass any number of values(attributes, parameters) to it and then inside the function these values can be processed and used, if function accepts **kwargs then any number of key/value pairs can be passed to the function that can be processed and used.
In Maya python **kwargs pattern is used for passing MEL flags to python cmds version of the MEL command. For example cmds.ls(sl=true) - "sl=true" is a key/value pair passed to cmds.ls function that accepts **kwargs.
That's my understanding, please correct me if I am wrong.
Yury
Hi, I understand what a non-keyword is, basically an argument, while a keyword is an variable inside and argument. What I'm having trouble understanding is *args & *kwargs. I found this site but I'm still stuck. I'm not too familiar with loops at the moment so the example used on the site mentioned throws me a curve ball.I'm hoping someone can re-interpret how to use *args & **kwargs ?
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/159b1d5c-9ba3-49a4-b94b-09fc8089e088%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, June 01, 2016 12:00 PM
Look at this site
http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/I would say looking at more examples will help.
The way I understand it - if function accepts *args then you can pass any number of values(attributes, parameters) to it and then inside the function these values can be processed and used, if function accepts **kwargs then any number of key/value pairs can be passed to the function that can be processed and used.
In Maya python **kwargs pattern is used for passing MEL flags to python cmds version of the MEL command. For example cmds.ls(sl=true) - "sl=true" is a key/value pair passed to cmds.ls function that accepts **kwargs.That's my understanding, please correct me if I am wrong.
Yury
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGScisHLKQc3CoNf5LhXdadRAMEvDM1%3DAk%3DkgKqskfQVwqrg%40mail.gmail.com.
Wednesday, June 01, 2016 11:03 AM
Hi, I understand what a non-keyword is, basically an argument, while a keyword is an variable inside and argument. What I'm having trouble understanding is *args & *kwargs. I found this site but I'm still stuck. I'm not too familiar with loops at the moment so the example used on the site mentioned throws me a curve ball.--I'm hoping someone can re-interpret how to use *args & **kwargs ?
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
yury - I did read that understanding args and kwargs may be a bit a of a hurdle. ;-) I'll go over the examples again, I got frustrated and posted hoping someone would explain with the perfect touch ;-)
That is not to say your touch is horrible, just a figure of speech !
Wednesday, June 01, 2016 12:00 PM
Look at this site
http://www.saltycrane.com/blog/2008/01/how-to-use-args-and-kwargs-in-python/I would say looking at more examples will help.
The way I understand it - if function accepts *args then you can pass any number of values(attributes, parameters) to it and then inside the function these values can be processed and used, if function accepts **kwargs then any number of key/value pairs can be passed to the function that can be processed and used.
In Maya python **kwargs pattern is used for passing MEL flags to python cmds version of the MEL command. For example cmds.ls(sl=true) - "sl=true" is a key/value pair passed to cmds.ls function that accepts **kwargs.That's my understanding, please correct me if I am wrong.
Yury
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CACqGScisHLKQc3CoNf5LhXdadRAMEvDM1%3DAk%3DkgKqskfQVwqrg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
Wednesday, June 01, 2016 11:03 AM
Hi, I understand what a non-keyword is, basically an argument, while a keyword is an variable inside and argument. What I'm having trouble understanding is *args & *kwargs. I found this site but I'm still stuck. I'm not too familiar with loops at the moment so the example used on the site mentioned throws me a curve ball.--I'm hoping someone can re-interpret how to use *args & **kwargs ?
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_maya+unsub...@googlegroups.com.
On 2 Jun 2016 1:03 AM, "Christopher." <crestchr...@gmail.com> wrote:
>
> I'm hoping someone can re-interpret how to use *args & **kwargs ?
def foo(*args, **kwargs):
print(args)
print(kwargs)
*args means the function/method accepts any number of arguments and those will be available as items of tuple named args.
*kwargs means the function/method accepts any number of keyword arguments and those will be available as items of dictionary named kwargs.
You can pick any name for the tuple/dict storing the arguments, it's just a local variable.
Hope this helps,
Cheers
On 2 Jun 2016 1:03 AM, "Christopher." <crestchr...@gmail.com
<mailto:crestchr...@gmail.com>> wrote:
>
> I'm hoping someone can re-interpret how to use *args & **kwargs ?
def foo(*args, **kwargs):
print(args)
print(kwargs)
*args means the function/method accepts any number of arguments and
those will be available as items of tuple named args.
*kwargs means the function/method accepts any number of keyword
arguments and those will be available as items of dictionary named
kwargs.
You can pick any name for the tupl e/dict storing the arguments, it's
just a local variable.
Hope this helps,
Cheers
--
You received this message because you are subscribed to a topic in the
Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/CAPamJi9Rd_1fNN7sWrOf4dgO-Wo1R%3D%3DJYU03yLbuFAmdPGK%3D0g%40mail.gmail.com
<https://groups.google.com/d/msgid/python_inside_maya/CAPamJi9Rd_1fNN7sWrOf4dgO-Wo1R%3D%3DJYU03yLbuFAmdPGK%3D0g%40mail.gmail.com?utm_medium=email&utm_source=footer>.
print('Ref1:
%s'%id(process_all_textures))
; Sunday, June 05, 2016 10:55 AM
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAPamJi9Rd_1fNN7sWrOf4dgO-Wo1R%3D%3DJYU03yLbuFAmdPGK%3D0g%40mail.gmail.com.
Wednesday, June 01, 2016 11:03 AM
Hi, I understand what a non-keyword is, basically an argument, while a keyword is an variable inside and argument. What I'm having trouble understanding is *args & *kwargs. I found this site but I'm still stuck. I'm not too familiar with loops at the moment so the example used on the site mentioned throws me a curve ball.
I'm hoping someone can re-interpret how to use *args & **kwargs ?
--
You received this message because you are subscribed to a topic in the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/python_inside_maya/3nLxyS7OS6U/unsubscribe.
To unsubscribe from this group and all its topics, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/159b1d5c-9ba3-49a4-b94b-09fc8089e088%40googlegroups.com.