Skip to content

Instantly share code, notes, and snippets.

@pykong pykong/
Last active Oct 22, 2017

What would you like to do?
Ordered those from "most Pythonic" to "least Pythonic" and "least efficient" to "most efficient". - the len(set()) solution is idiomatic, - but constructing a set is less efficient memory and speed-wise.
>>> lst = ['a', 'a', 'a']
>>> len(set(lst)) == 1
>>> all(x == lst[0] for x in lst)
>>> lst.count(lst[0]) == len(lst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.