Just playing with it here (Win, Maya 2012/x64) it comes up with a TypeError: 
not enough arguments for format string. I've not really used much % string 
formatting so I'm at a mild loss, but the same code works fine in say, IDLE, so 
I've a half guess it's how the code block is being passed through to the python 
interpreter 

Hm, in fact, I'll bet my hat on that - trying this:

print "This really should work, %s"%("right")

Gives me a *KeyError*. Traceback as follows:

#   File "<string>", line 2, in pythonFormat
# KeyError: u"'right'" //
# Error: invalid syntax
#  File "<maya console>", line 2
#  
#    ^
# SyntaxError: invalid syntax #

So whatever is mangling the text in the UI editor to get it into a python 
interpreter is doing something a tad odd to the string. Short answer appears to 
be not to use % based formatting, alas.




On 19 Jun 2014, at 11:52, Justin Israel <[email protected]> wrote:

> Can see a reason  for that to fail.  Does it just say syntax error? 
> On Jun 18, 2014 3:38 PM, "Brian Eyre" <[email protected]> wrote:
> Hi,
> 
> I was getting intermittent syntax errors from code entered into the popup 
> menu of a shelf button, and have narrowed it down to an issue with using '%' 
> in string formatting. Example:
> 
> text = 'working'
> print 'why is this command not %s'%text
> 
> I'm wondering if this is a known issue, or if anyone has a solution?
> 
> Cheers!
> 
> Brian. 
> 
> 
> 
> 
> 
> -- 
> 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/284cbc26-51e7-4fcd-9e5f-ddbbc4eba3d6%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/CAPGFgA1nHA1uO4fgSkyBo57qCgmmojASRxHkfMqrqLE8yoXb7A%40mail.gmail.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/B25BDE61-9BAB-4ED7-AFCA-0348C4F0FA74%40greenworm.net.
For more options, visit https://groups.google.com/d/optout.

Reply via email to