--
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/d32cb68b-135f-443a-923a-83d7ae1f3034%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Tue, 24 May 2016 8:09 AM <s...@weacceptyou.com> wrote:Hi just a quick one.
Why is it necessary to use .format():
for light in all_lights:
light_intensity = cmds.getAttr('{0}.intensity'.format(light))
rather than:
for light in all_lights:
light_intensity = cmds.getAttr(light + '.intensity')
they both work but i always see people using the .format() method, rather than just concatenating the strings. Is there a reason to use one rather than the other. The latter seems simpler also
thanks,
SamConcatenating strings creates maple copies
Concatenating strings creates maple copies along the way, as each pair is concatenated and a new string is return for for the next addition.
This is probably true, but come on. For performance?
This..
for light in all_lights:
light_intensity = cmds.getAttr(light + '.intensity')
..is a lot more readable than this..
for light in all_lights:
light_intensity = cmds.getAttr('{0}.intensity'.format(light))
And that makes it right.
ok i see, thanks Justin,
so the extra stuff generated by code in a script, like strings, how can they be problematic or wasteful?, do you mean they just use up memory or slow things down? I dont think i fully understand where the stuff that is created is stored, and does it only dissappear when you restart maya?
thanks,
Sam
--
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/a1ef0c1c-9c39-486c-81ef-b99ab3745e80%40googlegroups.com.
--
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/CAFRtmOCxFHER9TWi2QOa81uiB%3D73%3D3Ou3yMPO1woMBSUFzpj1Q%40mail.gmail.com.