Python Tutorial: List Comprehensions Step-By-Step

Pubblicato il: 05 aprile 2017
sul canale di: Real Python
54,609
1.2k

https://dbader.org/python-tricks ► See how to leverage Python's best features, like List Comprehensions, in your own programs

This video tutorial breaks down Python list comprehensions for you step by step. See how Python's comprehensions can be transformed from and to equivalent "for"-loops so you'll know exactly what's going on behind the scenes.

One of my favorite features in Python are list comprehensions. They can seem a bit arcane at first but when you break them down they are actually a very simple construct.

The key to understanding Python's list comprehensions is that they’re just for-loops over a collection expressed in a more terse and compact syntax.

In the video I also discuss when to use list comprehensions in your own Python programs and when not to. Basically, the caveat to Python’s comprehensions is this—as you get more proficient at using them it becomes easier and easier to write code that’s difficult to read. If you’re not careful you might have to deal with monstrous list, set, dict comprehensions soon. Too much of a good thing is usually a bad thing.

To deepen your learning also check out this longer tutorial article I wrote on Python's comprehensions, including dictionary comprehensions and set comprehensions: https://dbader.org/blog/list-dict-set...

FREE COURSE – "5 Thoughts on Mastering Python" https://dbader.org/python-mastery

SUBSCRIBE TO THIS CHANNEL: https://dbader.org/youtube

* *

► Python Developer MUGS, T-SHIRTS & MORE: https://nerdlettering.com

FREE Python Tutorials & News:
» Python Tutorials: https://dbader.org
» Python News on Twitter:   / @dbader_org  
» Weekly Tips for Pythonistas: https://dbader.org/newsletter
» Subscribe to this channel: https://dbader.org/youtube


In questa pagina del sito puoi guardare il video online Python Tutorial: List Comprehensions Step-By-Step della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Real Python 05 aprile 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 54,609 volte e gli è piaciuto 1.2 mille spettatori. Buona visione!