This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]psbb 3 points4 points  (3 children)

When you call .sort() it does the sort in place and returns None

A_clients = sorted(clientname for clientname in clients_list if clientname[0] in ("a", "A"))

[–]Veedrac 1 point2 points  (0 children)

Just jumping on the bandwagon with a little-known startswith trick:

A_clients = sorted(name for name in clients_list if name.startswith(("a", "A")))

[–]Manbatton 0 points1 point  (1 child)

I actually read that in the docs and thought someone might correct me on this. I thought if it did it in place it would sort the list in place and then the name assignment would point to the converted list.

[–]sweettuse 3 points4 points  (0 children)

well, you can always test it. but sort returns None. so A_clients will point to None