I hereby claim:
- I am svvitale on github.
- I am svvitale (https://keybase.io/svvitale) on keybase.
- I have a public key ASDTmkxAdl96XWG71bZe4C58UsDKQXlt8DaltryKd8ALYAo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
I absolutely love using operator overrides in low-level objects because it can make the caller's use case WAY more intuitive. There are certainly some pitfalls though.
__getitem__
and __setitem__
to make an object more dictionary-like, make sure to also override __iter__
OR __contains__
since they're called to handle membership tests like in
and not in
. (ref: https://docs.python.org/3/reference/expressions.html#membership-test-operations)Enums can be a little tedious in Python, but there are a few things I try to do to streamline usage:
using DYMO.Label.Framework; | |
namespace ConsoleApp1 | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Printers printers = new Printers(); | |
# -*- coding: utf-8 -*- | |
from __future__ import unicode_literals | |
from django.db import models, migrations | |
class Migration(migrations.Migration): | |
dependencies = [ | |
('spigot', '0034_hydrated_connection_view_v2'), |
import requests | |
class MyApiClient(requests.Session): | |
def do_something(self): | |
response = self.post('/some/url', json={ | |
'param1': 'a', | |
'param2': 'b' | |
}) | |
if response.status_code == requests.codes.ok: |
def fib_iterative(n): | |
sequence = (0, 1) | |
if n < 2: | |
return sequence[n] | |
for _ in range(n - 2): | |
sequence = (sequence[1], sequence[0] + sequence[1]) | |
return sequence[0] + sequence[1] |
import random | |
import string | |
import re | |
allowable = re.sub(r'[IO10]', '', (string.ascii_uppercase + string.digits)) | |
def combos(place): | |
for char in allowable: |
from setuptools import setup | |
from distutils.core import Extension | |
from distutils.command.build import build | |
import os | |
from subprocess import call | |
import multiprocessing | |
from glob import glob | |
from django.views.generic import View | |
from django.shortcuts import get_object_or_404 | |
from .decorators import json | |
from .models import RoomModel | |
from django.http import HttpResponse | |
class RoomView(View): | |
"""Room view class that implements the primary HTTP verbs (POST, GET, PUT, DELETE). |