<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 
Step1:  As you can see, it doesn't generate the complete list like the listcomp above. Genexps don't produce entire lists in memory. You need to iterate over them, and then you will get the item one by one. No one is keeping the entire list!
Step2:  Next, it's about tuple (in short, not just an immutable list), and slicing. More examples
Step3:  Next, the chapter moves on to list.sort() vs. sorted(). I kinda like sorted because it works with everything including generators, and it returns a new list. Whereas list.sort() is more limited because it is an in-place sort which returns None.
Next is about bisect, which is interesting but one can read the documentation easily and experiment with it.
Also obviously important is knowing which data structure meets your needs. A bit like knowing the Java Collections Framework again. What I don't really like about Python here is that the nicer and supposedly basic things are not part of the standard library. For example, SortedContainers is by all accounts an excellent package. This is something we've been taking for granted in Java for example. 
One notable thing from sorting that's different (and I agree with the author, is nicer) than in other languages is using the "key" argument instead of the usual "Comparator" function/object that returns the standard -1, 0, 1. Again, more examples
<ASSISTANT_TASK:>
Python Code:
couleurs = ["rouge", "orange", "jaune", "vert", "bleu", "indigo", "violet"]
tailles = ["page", "homme", "demi patron", "patron", "grand patron"]
[(couleur, taille) for couleur in couleurs for taille in tailles]
couleurs_et_tailles = ((couleur, taille) for couleur in couleurs for taille in tailles)
couleurs_et_tailles
couleurs_et_tailles = ((couleur, taille) for couleur in couleurs for taille in tailles)
couleurs_et_tailles
Explanation: 
End of explanation
for article in couleurs_et_tailles:
    print(article)
Explanation: As you can see, it doesn't generate the complete list like the listcomp above. Genexps don't produce entire lists in memory. You need to iterate over them, and then you will get the item one by one. No one is keeping the entire list!
End of explanation
jours = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"]
all_slice = slice(None, None, None)
print(jours[all_slice])
every_other_slice = slice(0, None, 2)
print(jours[every_other_slice])
reverse_slice = slice(None, None, -1)
print(jours[reverse_slice])
Explanation: Next, it's about tuple (in short, not just an immutable list), and slicing. More examples:
End of explanation
jours = ["lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi", "dimanche"] # already ordered
print(sorted(jours))
print(sorted(jours, reverse=True))
print(sorted(jours, key=len, reverse=True)) # by length of string, descend
print(sorted(jours, reverse=True, key=lambda x: jours.index(x))) # by actual order of week, descending
Explanation: Next, the chapter moves on to list.sort() vs. sorted(). I kinda like sorted because it works with everything including generators, and it returns a new list. Whereas list.sort() is more limited because it is an in-place sort which returns None.
Next is about bisect, which is interesting but one can read the documentation easily and experiment with it.
Also obviously important is knowing which data structure meets your needs. A bit like knowing the Java Collections Framework again. What I don't really like about Python here is that the nicer and supposedly basic things are not part of the standard library. For example, SortedContainers is by all accounts an excellent package. This is something we've been taking for granted in Java for example. 
One notable thing from sorting that's different (and I agree with the author, is nicer) than in other languages is using the "key" argument instead of the usual "Comparator" function/object that returns the standard -1, 0, 1. Again, more examples:
End of explanation
<END_TASK>