Python Tutorial: Comprehensions - How they work and why you should be using them
Video Statistics and Information
Channel: Corey Schafer
Views: 457,660
Rating: undefined out of 5
Keywords: Python (Programming Language), List Comprehensions, Python List Comprehensions, Comprehensions, Python Comprehensions, Set Comprehensions, Dict Comprehensions, Python Tutorials, Python Tutorial, Python, Programming, Programming Tutorials, Computer Science, Software, Software Engineering, Development, Programming Language (Software Genre), How to, How-to, Video Tutorial, Generators, Python Generators, Generator Expressions
Id: 3dt4OGnU5sM
Channel Id: undefined
Length: 18min 29sec (1109 seconds)
Published: Mon Aug 24 2015
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.
A good tip when learning comprehensions, or simply making them more readable, is to wrap them:
This technique helps more as code becomes more complex. The following would look horrible on a single line but is pretty neat when wrapped:
This is a nice summary of
[t + '-comprehensions' for t in ['list', 'dict', 'set']]
but he seems a little bit too opinionated about higher-order functions.map
,filter
andreduce
may be a bit complicated for the uninitiated, but once you comprehend list comprehensions and anonymous functions you also get these.Also: rimshot.