LML,

Kurian is using python string formatting:
http://docs.python.org/release/2.5.2/lib/typesseq-strings.html

In your line:
> pm.select('pCube5.f[myNum]')

the single quotes (') designate a literal string. If you want to have
a variable inserted in there, you need to use the string formatting
syntax described in the link above.

That is what Kurian is doing here:

> pm.select('pCube5.f[%s]',%myNum)

This means to take the value stored in 'myNum' (the variable right
after the last percentile (%)) and substitue it into the previous
string where there is a % 'specifier'. Pretty sure the comma is not
necessary.

If you want to substitute 2 strings, you'd use this syntax:

> print 'Python %s powerful, %s' % ('is', 'right?')

Little tricky at first, but easy to grok and powerful later on.

BTW, FYI, this is a generic Python issue, not PyMEL related.

-jason


On Mar 2, 2:23 pm, Kurian O.S ™ ® <[email protected]> wrote:
> myNum = 5
>
> for i in range(10):
>
>    pm.polyCube()
>    pm.move(0,0,i*2)
>
> pm.select('pCube5.f[%s]',%myNum)
> pm.delete()
>
> I hope this will work , and this the one of the best place to ask questions
> about pymel :-)
>
> On Fri, Feb 25, 2011 at 8:22 AM, LML <[email protected]> wrote:
> > myNum = 5
>
> > for i in range(10):
>
> >    pm.polyCube()
> >    pm.move(0,0,i*2)
>
> > pm.select('pCube5.f[myNum]')
> > pm.delete()
>
> --
> --:: Kurian ::--

-- 
http://groups.google.com/group/python_inside_maya

Reply via email to