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
import gevent | |
import gevent.pool | |
import gevent.event | |
import gevent.socket | |
import gevent.monkey | |
gevent.monkey.patch_all() | |
class UnhappyEyeballs(Exception): | |
pass |
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
""" | |
$ python example.py | |
1 + 1 is 2 | |
""" | |
from types import FunctionType | |
from codetransformer import Code | |
import codetransformer.instructions as instrs |
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
""" | |
$ python loop.py | |
Body: 0 | |
Body: 1 | |
Body: 2 | |
Body: 3 | |
Body: 4 | |
Skipping 5 | |
Body: 6 | |
Body: 7 |
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
In [44]: df | |
Out[44]: | |
a b | |
0 1 2 | |
1 2 3 | |
2 3 4 | |
In [45]: renamed = df.rename(columns={'b': 'c'}) | |
In [46]: renamed.iloc[0, 0] = 1000 |
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 __future__ import print_function | |
from contextlib import contextmanager | |
@contextmanager | |
def some_context_manager(x): | |
print("Entering", x) | |
yield | |
print("Exiting", x) |
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 codetransformer.transformers.switchcase import switch | |
def foo(x): | |
print("Start: x={}".format(x)) | |
with switch(x) as case: | |
@case(1) | |
def _1(): | |
# Read and write x. |
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 __future__ import print_function | |
import requests | |
import pandas as pd | |
from six.moves.urllib_parse import urlencode | |
def download_avocado_data(dest, start_date, end_date): | |
base_url = 'https://www.marketnews.usda.gov/mnp/fv-report-retail' |
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
import os | |
from unittest import TestCase | |
import psutil | |
import humanize | |
pid = os.getpid() | |
proc = psutil.Process(pid) | |
real_doCleanups = TestCase.doCleanups | |
OUTPUT_FILE = open('/home/ssanderson/pandas16_memory_usage.txt', 'w') |
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
# td is a TemporaryDirectory that's being deleted earlier than | |
# expected somewhere in my test suite. | |
import shutil | |
old_rmtree = shutil.rmtree | |
def rmtree(path, *args, **kwargs): | |
if path == td.name: | |
import nose.tools; nose.tools.set_trace() | |
return old_rmtree(path, *args, **kwargs) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder