>>> f" Ana ".center(50, "o")
'oooooooooooooooooooooo Ana ooooooooooooooooooooooo'
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Find class or methods override by Python silently.""" | |
import argparse | |
import os | |
import re | |
from pprint import pprint | |
CLASS_OR_METHOD = r'\b(class|def) (.*)\(' | |
CLASS_OR_METHOD_PATTERN = re.compile(CLASS_OR_METHOD) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# install dependencies from .cfg file (from https://stackoverflow.com/a/46573039/1344295) | |
python -c "import configparser; c = configparser.ConfigParser(); c.read('setup.cfg'); print(c['options']['install_requires'])" | xargs pip install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Migrate from model_mommy to model_bakery. | |
``python from_mommy_to_bakery.py --dry-run`` | |
Please check your dependency files. | |
""" | |
import argparse | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Migrate from model_mommy to model_bakery. | |
``python from_mommy_to_bakery.py --dry-run`` | |
""" | |
import argparse | |
import os | |
import re |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CRATE_SIZE = 24 | |
def beer_formula(rsvps): | |
minimum = 1.3 | |
maximum = 2 | |
return int(minimum * rsvps), int(maximum * rsvps) | |
MicroPython version for the Mäxchen game.
Requirements:
- Pyboard
- lcd160cr
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import pytest | |
@pytest.fixture | |
def file_factory(tmpdir): | |
def _file_factory(path): | |
full_path = Path(path) | |
file_name = full_path.name |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# stolen from https://stackoverflow.com/questions/20944483/python-3-sort-a-dict-by-its-values | |
[(k, d[k]) for k in sorted(d, key=d.get, reverse=True)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PrivateClassesView: | |
def post(self): | |
# code omitted for readability sake | |
data = { | |
'to': ['bla@bla.com'], | |
'body': 'blablabla', | |
'scheduled_for': datetime(2019, 3, 30, 11, 1, 0) | |
} | |
if subject: | |
data['subject'] = subject |