Skip to content

Instantly share code, notes, and snippets.

class A:
def method(self):
print(42)
class B(A):
def method(self):
print('overriding')
super( self.__class__, self ).method()
class C(B):
import requests
requests.post('https://upload.wistia.com',
{'url': 'https://s3.us-east-2.amazonaws.com/wistia-glitches/lenny-example-video.mp4',
'api_password':'your_api_password_from_wistia'})
import re
import tokenize
import astroid
def _build_assign(value):
return astroid.parse('_ = {}'.format(value)).body[0]
"""test for Python 3 string formatting error
"""
# pylint: disable=too-few-public-methods, import-error, unused-argument, line-too-long, no-absolute-import
import os
from missing import Missing
__revision__ = 1
class Custom(object):
""" Has a __getattr__ """
@PCManticore
PCManticore / a.py
Created August 4, 2015 16:50
pylint api
# Using a helper function to evaluate the result of .metaclass
from astroid.helpers import evaluate_metaclass
m = cls.metaclass()
real_m = evaluate_metaclass(m)
-----------------------
# Adding a keyword parameter
@PCManticore
PCManticore / gotcha.py
Last active August 29, 2015 14:20 — forked from vtemian/gotcha.py
# mutable list
def foobar(arg_string="abc", arg_list=[]):
print arg_string, arg_list
arg_string = arg_string + "xyz"
arg_list.append("F")
for i in range(4):
foobar()
@PCManticore
PCManticore / gist:723fc8da746f2d285fbd
Created April 8, 2015 21:52
Simple sprunge-like command
#!/bin/bash
VALUE=$(cat)
echo $VALUE | curl -F 'sprunge=<-' http://sprunge.us
from fields import Tuple
import abc, six
@six.add_metaclass(abc.ABCMeta)
class Pair(Tuple.a.b):
@abc.abstractmethod
def test(self):
pass
from collections import defaultdict
d = defaultdict(int)
d[4] = 5
for i in d:
if not d[3]:
# watch it burn.