Skip to content

Instantly share code, notes, and snippets.

View yamyamyuo's full-sized avatar
🎯
Focusing

yamyamyuo

🎯
Focusing
View GitHub Profile
@yamyamyuo
yamyamyuo / argparser_best_practive.py
Created October 11, 2018 06:00
python argparser
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument(
"--verbose",
help="turn on debug mode",
default=False,
action='store_true')
parser.add_argument(
"--process-lock-file", help="process file lock", required=True)
@yamyamyuo
yamyamyuo / test-datetime-json-dumps.py
Created October 10, 2018 08:24 — forked from drmalex07/test-datetime-json-dumps.py
Create JSON dumps aware of datetime.datetime objects, in Python. #json #python #dumps #datetime
import json
import datetime
'''Create an encoder subclassing JSON.encoder.
Make this encoder aware of our classes (e.g. datetime.datetime objects)
'''
class Encoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, datetime):
return obj.isoformat()