Filter criteria via python, how?

Hello Dynos,

I discovert a nice short code:

x = IN[0]

x.sort(key = len)

OUT = x

Which other keys (= len)can i generate? like:

can i say key = startwith lowercase or uppercase

does anyone know more “vocabulary”?

KR

Andreas

1 Like

for ‘contains’ you can use ‘in’ statement ( if sub_string in string: )
there is also ‘startswith’ and ‘endswith’ ( string.startswith(‘beginning’) )

One more handy thing for the sort function are lambda expressions. They allow you to do things like this:

a.sort(key = lambda x: x.Name )

or

a.sort(key = lambda b: b.x + b.y + b.z )

1 Like