General statistics
List of Youtube channels
Youtube commenter search
Distinguished comments
About
Lawrence D’Oliveiro
Lex Fridman
comments
Comments by "Lawrence D’Oliveiro" (@lawrencedoliveiro9104) on "Best feature of Python | List Comprehensions" video.
That would mean that every class type would have to provide methods implementing this functionality, whereas with the Python way, it only needs to be implemented once, as a built-in function.
1
However, note a language inconsistency. While [isinstance(i, int) for i in sample_list] is equivalent to list(isinstance(i, int) for i in sample_list) which computes the same list as l = (isinstance(i, int) for i in sample_list) l = list(l) These are not equivalent to l = (isinstance(i, int) for i in sample_list) l = [l] which returns only a list of a single element, being the generator object. This seems like a deliberate design decision.
1