longname= kwargs.get('longname', kwargs.get('ln'))
othervalue= kwargs.get('othervalue', kwargs.get('ov'))is how I handle it On Wed, Jan 7, 2015 at 10:37 AM, Jesse Kretschmer <[email protected]> wrote: > You could perhaps use tuples as the key for your 'preset' dictionary. This > will not allow for a simple .update(), but it's not complicated. > > Consider this: > > def mayaCommandWrapper(**kwargs): > preset = { > ('selection', 'sl'): True, > ('dagObjects', 'dag'): True, > } > > for key, value in preset.items(): > long_flag, short_flag = key > if long_flag not in kwargs and short_flag not in kwargs: > kwargs[long_flag] = value > > maya.cmds.ls(**kwargs) > > > On Wed Jan 07 2015 at 3:15:34 AM David Lantos <[email protected]> wrote: > >> Hi guy! >> >> I am just wondering have you guys a good solution/method to maintain >> python kwargs both short and long keywords with the same value. >> (I have a couple of ideas just I am courius someone has better one.) >> >> For example: >> >> There is a method that eats one keyword at time (for example: "longFlag" >> or "shortFlag"). It can accept a short and long keyword as well and we want >> to provide a preset for this keyword if user do not use either of them. >> Here is the frame: >> >> >> def mayaCommandWrapper(**kwargs): >> """ :keyword longFlag(shortFlag): This is a keyword flag can accept >> any value. """ >> preset = {} # Some dictionary preset here >> >> # Some solution here to provide long and short flags as well. >> >> preset.update(kwargs) # we want to overwrite preset with value if given >> any kind of flag. >> mayaCommand(**preset) # we give the dict to the maya command as kwargs. >> >> -- >> 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/ea14b9fa-7e6b-4c8f-bd9d-8d396b7c5189%40googlegroups.com >> <https://groups.google.com/d/msgid/python_inside_maya/ea14b9fa-7e6b-4c8f-bd9d-8d396b7c5189%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> 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/CANESWi30PEPtVBTXSUKLVg7j%2BY3BXLPxBxw72imt_fXqcLnBUg%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CANESWi30PEPtVBTXSUKLVg7j%2BY3BXLPxBxw72imt_fXqcLnBUg%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > 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/CAM9RXo%2BRZd67_oSuZYZE9iAqA8TDwkD15bVWgtUUv-pUEbtdCQ%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
