It always goes after the string, no matter what. It is a method of a string

cmds.getAttr(curves['curve{}'.format('xyz')].spans*2+1

But you can avoid hard to read lines and break it apart

curve = curves['curve{}'.format('xyz')]
spans = cmds.getAttr('{}.spans'.format(curve))
spans = spans * 2 + 1

On Mon, 6 Jun 2016 7:00 AM <[email protected]> wrote:

> hey,
>
> i understand using .format i can substitute in a value into the middle of
> string
>
> eg.
>
> word = 'cat'
> print 'the {} sat on the mat'.format(word)
>
> but what if you want to substitute in a string into a line which has other
> operations at the end. Like this example
>
> cmds.getAttr(curves['curve{}'].spans*2+1
>
> here i am accessing a curve from a dictionary and finding its span value
> and then multiplying by 2 + 1.
>
> So where in this line can i put the .format(value) ?. I cant put it right
> at the end or put it right after the string in between the string and the ].
>
> can someone help me understand how i can do this. Using the concatenation
> + doesnt work either because is just returns:
>
> unsupported operand type(s) for +: 'NoneType' and 'str'
>
> any help on this would be nice,
> 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 [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/9d99b0ee-88f3-4a44-9263-0bf8012c1a4b%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA1itOWKkPM-auj0mGY%3D9mEjcz%3DY6gL2fY6%2B%2B0HkvfMO-Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to