Here's a no-'if-statement'-solution: for i in cmds.ls(sl=True) or []: print i
It's ugly as well... so I use pymel... :) Ofer On Fri, Feb 6, 2009 at 6:18 PM, yury nedelin <[email protected]> wrote: > it's not Pymel I worry about it's about one hundred people that sit around > me that will be using the script, and their computers and the IT that will > set it up and version software and 64 bit verses 32 bit crap, and the rest. > I am just trying to keep things as bare bone as I can. I am sure Pymel is > good, I only hear good things about it. > > Yury > > > > On Fri, Feb 6, 2009 at 5:30 PM, chadrik <[email protected]> wrote: > >> yuri, you're not missing anything, that's just the way that it works. >> they fixed some of the list/None issues in later versions of maya, but not >> many of them. >> >> so, in general, you have 2 choices: wait for maya to fix its bugs and >> design flaws or fix them yourself. you can go through and start wrapping >> all the commands that have this design flaw, but then you'd just end up >> doing what pymel already does. catch 22. >> >> i also find it ironic that you say pymel has more bugs, when pymel >> actually fixes bugs in maya. there are two ways to use pymel: you can use >> it as a simple replacement for maya.cmds and program as you always have, but >> without these annoying bugs. or you can go further and start using the real >> power of pymel, which lies in its extensions and additions to maya.cmds >> >> its your choice. live with it or do something about it. >> >> -chad >> >> >> >> >> On Feb 6, 2009, at 4:55 PM, yury nedelin wrote: >> >> >> >> On Fri, Feb 6, 2009 at 4:02 PM, yury nedelin <[email protected]> wrote: >> >>> Hey Ryan, >>> >>> yes >>> using "if" is fine, it just seem not very elegant. >>> >>> I do not like having to check all the time. >>> >>> Pymel is cool but I want to stick with maya python as it comes with maya. >>> >>> Fewer special needs fewer bugs. >>> >>> I guess its I will have to keep checking >>> >>> Maya should return empty list instead of nothing. But I might still be >>> missing something. >>> >>> Yury >>> >>> >>> On Fri, Feb 6, 2009 at 3:19 PM, ryant <[email protected]> wrote: >>> >>>> >>>> I dont think his question has anything to do with pymel. My point was >>>> if you use the if statement as designed it doesnt matter what the >>>> value is that is returned. Python returns True if the value is usable >>>> and false if it is not. Dont get me wrong I took a look at pymel and >>>> you guys are doing some great things with it. >>>> >>>> None == False >>>> 0 == False >>>> 1 == True >>>> 2 == True >>>> [] == False >>>> [0] == True >>>> {} == False >>>> {1:1} == True >>>> () == False >>>> (1) == True >>>> >>>> >>>> >>>> On Feb 6, 2:29 pm, chadrik <[email protected]> wrote: >>>> > use pymel :) >>>> > >>>> > On Feb 6, 2009, at 1:25 PM, yury nedelin wrote: >>>> > >>>> > > let say >>>> > >>>> > > mc.select(clear=1) >>>> > > print mc.ls(sl=1) >>>> > > >>None >>>> > >>>> > > I have to check if its "None" or a list if I want to do a For loop >>>> > > anything else with the List >>>> > >>>> > > Are there better ways than checking >> if "None" >> all the time ? >>>> > >>>> > > Thanks >>>> > > Yury >>>> >>>> >>> >> >> >> >> >> >> >> > > > > -- - Ofer www.mrbroken.com --~--~---------~--~----~------------~-------~--~----~ Yours, Maya-Python Club Team. -~----------~----~----~----~------~----~------~--~---
