A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
import datetime as dt | |
import pytz | |
date_time_str = '2021-01-06T01:10:54.269' | |
date_time_obj = dt.datetime.strptime(date_time_str, '%Y-%m-%dT%H:%M:%S.%f') | |
timezone = pytz.timezone('UTC') | |
timezone_date_time_obj = timezone.localize(date_time_obj) | |
timezone_date_time_now = dt.datetime.now(pytz.utc) |
import itertools | |
from operator import itemgetter | |
sorted_animals = sorted(animals, key=itemgetter('size')) | |
animals = [{'name':'cow', 'size':'large'},{'name':'bird', 'size':'small'},{'name':'fish', 'size':'small'},{'name':'rabbit', 'size':'medium'},{'name':'pony', 'size':'large'},{'name':'squirrel', 'size':'medium'},{'name':'fox', 'size':'medium'}] | |
for key, group in itertools.groupby(sorted_animals, key=lambda x:x['size']): | |
print key, | |
print list(group) | |
# Getting class name | |
MyClass(x).__name__ | |
# UTC timestamp 2020-03-04T17:50:26.376Z | |
now = datetime.datetime.utcnow() | |
timestamp = now.strftime('%Y-%m-%dT%H:%M:%S') + \ | |
'.%03d' % (now.microsecond / 1000) + 'Z' | |
# Jupyter arguments |
// EXPRESSIONS AND VALUES | |
// A variable declared with the const keyword can’t be reassigned. This restriction is a good thing. | |
const hola = 'Hola'; | |
// TYPES | |
const arreglo = [1, 2, 3]; | |
const a = 'a'; | |
const b = 'b'; |
<?php | |
namespace NoxLogic\DemoBundle\Form\Type; | |
use Doctrine\ORM\EntityManager; | |
use NoxLogic\DemoBundle\Entity\Province; | |
use Symfony\Component\Form\AbstractType; | |
use Symfony\Component\Form\FormBuilderInterface; | |
use Symfony\Component\Form\FormEvent; | |
use Symfony\Component\Form\FormEvents; |