Example Gist as exercise.
This is the description, and THIS FILE IS MANDATORY.
You can include your markdown description here.
| { | |
| "a": 4, | |
| "b": 5 | |
| } |
| { | |
| "a": 4, | |
| "b": 5, | |
| } |
Example Gist as exercise.
This is the description, and THIS FILE IS MANDATORY.
You can include your markdown description here.
In this exercise you will read in a delimited data file as a list of records. Each record will be an instance of InventoryItem. The format of the delimited file is unusual, but can be handled by the Python csv module with appropriate configuration.
For example, the first few lines of data/Inventory.txt contain:
Name|Price|Quantity
/Wankle rotary engine/|555.55|527
/Sousaphone w%/ stand/|333.33|123
Feather Duster|22.22|900
| # !pip install python-hn | |
| import itertools | |
| from hn import search_by_date | |
| results = search_by_date('Who is hiring?', ask_hn=True, author='whoishiring', hits_per_page=1000) | |
| who_is_hiring = (r for r in results if 'ask hn: who is hiring?' in r['title'].lower()) | |
| for elem in itertools.islice(who_is_hiring, 10): | |
| print(elem['title']) |
| # !pip install python-hn | |
| import itertools | |
| from hn import search_by_date | |
| results = search_by_date('Who is hiring?', ask_hn=True, author='whoishiring', hits_per_page=1000) | |
| who_is_hiring = (r for r in results if 'ask hn: who is hiring?' in r['title'].lower()) | |
| for elem in itertools.islice(who_is_hiring, 10): | |
| print(elem['title']) |
| { | |
| "category_name": "General", | |
| "todos": [ | |
| { | |
| "task": "My TODO Task", | |
| "due_on": null, | |
| "status": "pending", | |
| "description": null | |
| }, | |
| { |
This is a quick Python script I wrote to download HumbleBundle books in batch. I bought the amazing Machine Learning by O'Reilly bundle. There were 15 books to download, with 3 different file formats per book. So I scratched a quick script to download all of them in batch.
(Final Result: books downloaded)
| from concurrent.futures import ProcessPoolExecutor | |
| class CheckOnlyIntegers: | |
| def __init__(self, fn): | |
| self.fn = fn | |
| def __call__(self, *args): | |
| if not all([type(arg) == int for arg in args]): | |
| raise ValueError("Invalid param is not an integer") |