tech:python-draft
Différences
Ci-dessous, les différences entre deux révisions de la page.
| Les deux révisions précédentesRévision précédente | |||
| tech:python-draft [2025/04/15 17:15] – Jean-Baptiste | tech:python-draft [2025/05/26 18:56] (Version actuelle) – Jean-Baptiste | ||
|---|---|---|---|
| Ligne 3: | Ligne 3: | ||
| # Draft Python3 | # Draft Python3 | ||
| + | |||
| + | ## List comprehensions and generator expressions | ||
| + | |||
| + | | ||
| + | |||
| + | ~~~python | ||
| + | line_list = [' | ||
| + | |||
| + | # Generator expression -- returns iterator | ||
| + | stripped_iter = (line.strip() for line in line_list) | ||
| + | |||
| + | # List comprehension -- returns list | ||
| + | stripped_list = [line.strip() for line in line_list] | ||
| + | |||
| + | stripped_list = [line.strip() for line in line_list if line != "" | ||
| + | ~~~ | ||
tech/python-draft.1744730140.txt.gz · Dernière modification : de Jean-Baptiste
