You can actually pack your keyword args into a dictionary and pass it into
the command like:
kw = {flag: value}
mc.frameLayout(self.frame, **kw)
On Wed, May 29, 2013 at 2:06 PM, ynedelin <[email protected]> wrote:
> hey guys
> I have this piece of code working fine, but us there a nicer way to do
> this without pre-building the string for eval?
>
> def frame(self, **kwargs):
> self.frame = mc.frameLayout()
> for flag, value in kwargs.iteritems():
> try:
> if type(value) is int or type(value) is float:
> cmd = "mc.frameLayout('%s', edit=1, %s=%f)"%(self.frame, flag,
> value)
> elif type(value) is str:
> cmd = "mc.frameLayout('%s', edit=1, %s='%s')"%(self.frame, flag,
> value)
> eval(cmd)
> except:
> traceback.print_exc()
>
> Yury
>
>
> --
> 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 post to this group, send email to [email protected].
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
>
--
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 post to this group, send email to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.