Sorting is simplified in Python with sorted(). You can even sort with complex rules.
Python Tip #8 - reducing looping by using dicts
In situations where you have a list of objects and have to retrieve then in random order, dictionaries can act as lookup tables.
Python Tip #7 - getattr()
Sometimes we have to deal with external objects and their attributes. getattr() can save you at those times.
Python Tip #6 - Merging Dictionaries
Merge or combine dictionaries
Python Tip #5 - Get value from dict if key is present
Check for existence of a key in dictionary and retrieve its value if present.
Python Tip #4 - Find an element in a list satisfying condition
What if you want to find the first item that matches the condition instead of getting a list of items?
Python Tip #3 - Filtering Lists
Selecting elements from a list that satidfy a condition
Sensible Test Data
I am currently working on a project called Peer Feedback, where we are trying to build a nice peer feedback system for college students. We use Canvas Learning Management System (CanvasLMS) API as the data source for our application. All data about the students, courses, assignments, submissions are all fetched from CanvasLMS. The application is written in Python Flask.
Python Tip #2 - Single Line if Statements
```python
Setting a value based on condition
if condition: choice = “Head” else: choice = “Tail”
Python Tip #1 - Setting flags without using if statements
When you have to check for the presence of a value in a list and set a flag based on it, we can avoid typical: