David Mertz wrote: > The pattern of "Create an empty collection, then add stuff in a loop" is > quite common, ...
Or you can use comprehensions, in which case there's no need for creating an empty collection. s = {f(x) for x in some_list} vs s = set() for x in some_list: s.add(f(x)) _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3ZEFFBQMMEG3BHE45SOHB2P4G73C7DC3/ Code of Conduct: http://python.org/psf/codeofconduct/