python - Compare and grab items attributes -


I have 3 locators in my view, e.g. Locator 01 - Local Scaleway 1 Price - Locator 02 - Local Scale Y Value 2 Locator - 3 - Value of Local Scale 3

With each different value in my local scales with each of these 3 locators The local scalar wanted to compare the values ​​and wanted to capture the highest (in this case this locator would be 03) yv = ymax = [] at pm.ls for yValue ('Unicorner * '): YMax.append (getAttr (yValue +' local.ScaleY ')) yMaxValue = maximum (yMax) print yMaxValue

So on the basis of coding above, is it a viable way to write as I would compare more items? Or maybe a better way?

Generate scale / object tuple generators, and max the first scale of that By putting it on, close the max key.

  locators = (getAttr (locator + 'local.ScaleY'), locator) for locator in pm.ls ('locator *')) yMaxValue, locator = maximum (locators)  

Some output for reference:

  & gt; & Gt; & Gt; Listings (Locators) # Result: [(1.0, NT transform (u'locator01 ')), (2.0, NT Transform (u'locator02')), (3.0, NT transform (u'locator03 ')), (1.0, NT.Locator (u'locator0Shape1 ')), (2.0, NT.Locator (u'locator0Shape2')), (3.0, NT.Locator (u'locator0Shape3 '))] # # & Gt; & Gt; YMaxValue # Result: 3.0 #> gt; & Gt; & Gt; Locator # Result: nt.Locator (u'locator0Shape3 ') #  

Comments