- 7 Tips for writing better Python: https://www.youtube.com/watch?v=VBokjWj_cEA
- TIMESTAMPS
- enumerate()
- zip()
- Swapping values
- Checking key in dictionary
- for ... else
- File reading, 'with'
- Exception Handling
- One line ‘IF’ statement:
'Yes' if fruit == 'Apple' else 'No'
- Check for 'None' values in a dictionary. If key = None, remove the key from the dictionary
for key in list(body):
if not body[key]:
body.pop(key)
- Need SSL certificate for SSL error, otherwise set:
verify=false
- tqdm library for timing programs
for company in tqdm(no_match_list_one, desc='Stage 2 matching', leave=True):
{logic}
- to make it faste: http://rpiai.com/faster-string-matching/
for enum_name, event in enumerate(range(events)):
print("Enum: {} || Event: {}".format(enum_name, event))
# Enum: 0 || Event: 0
# Enum: 1 || Event: 1
# Enum: 2 || Event: 2
# Enum: 3 || Event: 3
# Enum: 4 || Event: 4
for enum_name, event in enumerate(range(5), 1):
print("Enum: {} || Event: {}".format(enum_name, event))
# Enum: 1 || Event: 0
# Enum: 2 || Event: 1
# Enum: 3 || Event: 2
# Enum: 4 || Event: 3
# Enum: 5 || Event: 4
- Mocking API requests with unittest: http://engineroom.trackmaven.com/blog/real-life-mocking/
- Step-by-Step introduction: https://dbader.org/blog/python-decorators
- Data type conversion = 2 ways, implicit (coercion) and explicit (casting)
- implicit = 4.0 / 2 = 2.0 (automatically converts to float)
- explicit = str(4) or float(4)