This file contains hidden or 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
>>> f.keys() | |
[] | |
>>> f._OrderedDict__root[0][0][0][0][0][0][0][0][0][0] | |
[[...], [...], None] | |
>>> f._OrderedDict__root[0][1][0][1][0][1][0][1][0][1][0] | |
[[...], [...], None] |
This file contains hidden or 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
import os | |
import asyncio | |
import sys | |
from asyncio.streams import StreamWriter, FlowControlMixin | |
reader, writer = None, None | |
@asyncio.coroutine | |
def stdio(loop=None): |
This file contains hidden or 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 overload import overload | |
@overload | |
def hello(name: str): | |
print('Hello, %s!' % name) | |
@overload | |
def hello(name: int): |
This file contains hidden or 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
#!/usr/bin/env python2 | |
import argparse | |
import contextlib | |
import logging | |
import re | |
import os | |
import sys | |
import types |
This file contains hidden or 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
import asyncio | |
class AsyncInitMeta(type): | |
@asyncio.coroutine | |
def __call__(cls, *args, **kwargs): | |
self = cls.__new__(cls) | |
yield from self.__init__(*args, **kwargs) | |
return self |
This file contains hidden or 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 unittest import mock | |
class AttributeTrackMock(mock.Mock): | |
def __init__(self, *args, **kwargs): | |
super().__init__(*args, **kwargs) | |
self.attr_accesses = [] | |
def __getattr__(self, attr): | |
res = super().__getattr__(attr) | |
self.attr_accesses.append(res) |
This file contains hidden or 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
import cffi | |
ffi = cffi.FFI() | |
ffi.cdef('int PyDict_DelItemString(void *, const char *key);') | |
lib = ffi.dlopen('libpython3.so') | |
d = {'foo': 'bar'} | |
print('before', d) | |
d_p = ffi.cast('void*', id(d)) | |
lib.PyDict_DelItemString(d_p, ffi.new('char[]', b'foo')) |