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
In [1]: def f(): | |
...: def g(): | |
...: yield | |
...: return g | |
...: | |
In [2]: g = f() | |
In [3]: g().__qualname__ | |
Out[3]: 'f.<locals>.g' |
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
""" | |
In [1]: from the_worst_way import why_though | |
In [2]: import ast | |
In [3]: code = ''' | |
...: if a == 1 and a == 2 and a == 3: | |
...: print('ayy') | |
...: else: | |
...: print('lmao') |
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
"""Tested with: | |
- cython==0.27.3 | |
- cython==0.25.2 | |
""" | |
cdef class PairWithConstructor: | |
cdef int a; | |
cdef int b; |
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 python | |
import os | |
import statistics | |
import subprocess | |
from time import time as _time | |
class time: | |
def __init__(self): | |
self._start = 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
"""Example usage: | |
In [1]: !cat ayy.s | |
.text | |
.global _start | |
.type _start, @function | |
_start: | |
movq $10, %rdx | |
pushw $10 |
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 pandas as pd | |
import networkx | |
import toolz | |
df = pd.read_csv('/home/joe/downloads/debug.csv', escapechar='\\') | |
df.columns = ['stack', 'module', 'function', 'lineno', 'id', 'type', 'repr'] | |
g = networkx.DiGraph() |
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
""" | |
$ qipython -i ~/projects/tmp/lazy_talk_code.py | |
Python 3.4.6 (default, Feb 16 2017, 15:43:12) | |
Type "copyright", "credits" or "license" for more information. | |
IPython 5.3.0 -- An enhanced Interactive Python. | |
? -> Introduction and overview of IPython's features. | |
%quickref -> Quick reference. | |
help -> Python's own help system. | |
object? -> Details about 'object', use 'object??' for extra details. |
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
In [1]: class Descr: | |
...: def __init__(self): | |
...: self.get_counter = 0 | |
...: | |
...: def __get__(self, instance, owner): | |
...: if instance is None: | |
...: return self | |
...: self.get_counter += 1 | |
...: return 1 | |
...: |
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
""" Example: | |
In [5]: class Class: | |
...: def __init__(self, a, b): | |
...: self.a = a | |
...: self.b = b | |
...: | |
...: @self_scope | |
...: def f(self): | |
...: return a + b |
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
class WithLazyDoc: | |
def __init__(self, get_doc, f): | |
self._get_doc = get_doc | |
self._f = f | |
@property | |
def __wrapped__(self): | |
return self._f | |
@property |