Python: Do This, Not That!
0.0.1
Contents
1. Collection initialization
2. Chained comparison operators
3. Falsy and truthy
4. Ternary operator
5. Looping over a range of numbers
6. Looping backward
7. Looping over a collection
8. Looping over a collection with indices
9. Looping over two collections
10. Use list comprehensions
11. Filtering a list
12. Most frequent item in list
13. Default dictionary values: defaultdict
14. Accessing a dictionary value with a default value
15. Updating dictionaries
16. Merging dictionaries
17. Using a dictionary to store counts
18. Dictionary comprehension
19. Set comprehension
20. Unpacking sequences and tuples
21. Ignoring unpacked values from a tuple
22. Avoid accessing tuple elements by index
23. String concatenation
24. String interpolation
25. String debug
26. Don’t repeat yourself (DRY)
27. String reversal
28. Clarify function calls with keyword arguments
29. Lambdas
30. Generator functions
31. New vs old classes
32. Classes and dunders (double underscores)
33. Enumerations
34. Transforming data with map, filter, reduce
35. Flattening data
36. Caching data and results
37. Reading a file
38. Deleting a file
39. Filtering files
40. Saving objects to file
41. Combinations of a list
42. Cycling through a list
43. Product of lists
44. Simultaneous state updates
45. Pandas apply and numpy vectorization
Python: Do This, Not That!
Search
Please activate JavaScript to enable the search functionality.