If you'd like to learn more about pymel this is a great book.
check out Practical Maya Programming with Python:
http://www.amazon.com/Practical-Programming-Python-Robert-Galanakis/dp/1849694729/ref=sr_1_1?ie=UTF8&qid=1426095687&sr=8-1&keywords=practical+maya+programming+with+python

and I hear these videos are okay ;)  (shameless plug)
http://www.cgcircuit.com/course/intro-to-pymel-part-1






On Wed, Mar 11, 2015 at 6:21 AM, Paul Molodowitch <elron...@gmail.com>
wrote:

> From a functional standpoint, there isn't a difference. There may be a
> performance difference, but unless you're making thousands, I wouldn't
> worry about it.
>
> Generally speaking, if I usually expect it to exist, and want to use it as
> a PyNode if it does, I'll do the try/except thing.  One note though - you
> should probably do:
>
> try:
>     pmc.PyNode(string)
> except pmc.MayaNodeError:
>     print "something"
>
> It's bad practice to have blanket except statements** - particularly if
> you're "expecting" a certain type of error. Get in the habit of having
> targeted try excepts, and you'll save yourself from headaches down the road.
>
> - Paul
>
> **There are always exceptions, of course - for instance, if you're running
> an app and don't want an unknown error to bring everything to a halt, it
> can make sense to have some generic high-level try/except statements.  And
> in those cases, you'll probably want to at least print some sort of warning
> or traceback, or maybe log it to an error log, or email a bug report, etc.
> Also, even then, it's better to do "except Exception as e:" or "except
> Exception:" instead of "except:", because the latter will catch strange
> things you almost certainly don't want to - ie, if the user presses ctrl-c,
> or even if you've explicitly tried to call sys.exit!
>
>
> On Wed, Mar 11, 2015 at 12:32 AM, Panupat Chongstitwattana <
> panup...@gmail.com> wrote:
>
>> Ah thank you. Such a silly mistake :(
>>
>> Is there any draw back if I don't check objExists but instead go for this?
>>
>> try:
>>     PyNode(string)
>> except:
>>     print "something"
>>
>>
>>
>> On Wednesday, March 11, 2015 at 2:02:06 PM UTC+7, Justin Israel wrote:
>>>
>>> You have a typo between the two ways you format the string :
>>>
>>> tmpname = "%smaster_crtl" % sel.namespace()
>>> tmp = "%smaster_ctrl" % selects[0].namespace()
>>>
>>> crtl vs ctrl
>>>
>>> On Wed, 11 Mar 2015 7:02 PM Panupat Chongstitwattana <panu...@gmail.com>
>>> wrote:
>>>
>>>> Hi.
>>>>
>>>> I ran into another problem. objExists is returning different result
>>>> when I put it in a for loop.
>>>>
>>>> selects = pmc.selected()
>>>>
>>>> for sel in selects:
>>>>     tmpname = "%smaster_crtl" % sel.namespace()
>>>>     print tmpname
>>>>     print pmc.objExists(tmpname)
>>>> # SC05A_0110_ECh_LoopAnim_v002:SC05A_0020_Extra_Cheer_
>>>> LoopAnim_v001:exMaleHair001:master_ctrl
>>>> # False
>>>>
>>>> tmp = "%smaster_ctrl" % selects[0].namespace()
>>>> print tmp
>>>> print pmc.objExists(tmp)
>>>> # SC05A_0110_ECh_LoopAnim_v002:SC05A_0020_Extra_Cheer_
>>>> LoopAnim_v001:exMaleHair001:master_ctrl
>>>> # True
>>>>
>>>> What could be the cause of this?
>>>>
>>>>
>>>>   --
>> 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 python_inside_maya+unsubscr...@googlegroups.com.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/python_inside_maya/8f3151a3-7a9b-4fdc-8721-f8cb60d35c10%40googlegroups.com
>> <https://groups.google.com/d/msgid/python_inside_maya/8f3151a3-7a9b-4fdc-8721-f8cb60d35c10%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 python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/CAAssL7bjy%2BHYmO0o4byZMrWSZ%2BmThofJkZkUD8O_HgwoBDhZ0g%40mail.gmail.com
> <https://groups.google.com/d/msgid/python_inside_maya/CAAssL7bjy%2BHYmO0o4byZMrWSZ%2BmThofJkZkUD8O_HgwoBDhZ0g%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 python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CABPXW4gmpDtf4xUZoswg5Tejvqv4-BQfx8c3Q1WLF1DfQiLZww%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to