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
[shuchen@archy stuff]$ python2.7 a.py | |
module A being imported! | |
module B being imported! | |
module A being imported! | |
hollering from A | |
hollering from A |
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 string | |
import sys | |
class count_dict(dict): | |
""" | |
stub object used to simplify tracking | |
the number of letters encountered. | |
this expects to be initialized with an uppercase letter yo. | |
""" |
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
(py27)[shuchen@archy Downloads]$ cat test.py | |
from docutils.core import publish_string | |
import pstats, cProfile | |
fn = 'foo.rst' | |
profile_fn = fn + '.prof' | |
with open(fn) as fh: | |
data = fh.read() | |
def gogogo(): |
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
>>> a = lambda x: 1000 | |
>>> a | |
<function <lambda> at 0xb77f88b4> | |
>>> a(1) | |
1000 | |
>>> (id(a(1)), id(a(1))) | |
(143414124, 143414124) | |
>>> (id(a(1)), id(a(2))) | |
(143414124, 143414124) | |
>>> def return_1000(): return 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
22133421413223443 | |
24211233443411322 | |
31344411143241232 | |
41231323412144134 | |
31112324234443221 | |
13324314412212323 | |
31424223321414413 | |
43121113244323412 | |
44334242312321211 | |
12221344143334241 |
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
2011-10-15 05:05:59 dxq hi friends | |
2011-10-15 16:51:41 dxq hi friends | |
2011-10-26 04:26:09 dxq hi friends | |
2011-10-28 04:40:37 dxq hi friends | |
2011-10-29 03:47:19 dxq hi friends | |
2011-11-02 19:44:43 sixthgear hi friends | |
2011-11-04 02:44:14 dxq hi friends | |
2011-11-08 02:47:33 dxq hi friends | |
2011-11-08 23:50:36 dxq hi friends | |
2011-11-11 00:56:49 dxq hi friends |
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
def DecorateEverything(decorator): | |
"""Function that returns a metaclass that decorates | |
all class callables (except those starting with __) | |
with `decorator`.""" | |
class DEMeta(type): | |
def __init__(cls, name, bases, dct): | |
new_dct = {} | |
for k, v in dct.iteritems(): | |
if hasattr(v, "__call__") and not k.startswith('__'): | |
setattr(cls, k, decorator(v)) |
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
def one(iterable, condition=None): | |
"""True if only one value in the iterable evaluates to True.""" | |
if condition is None: | |
condition = bool | |
gen = (i for i in iterable if condition(i)) | |
try: | |
gen.next() | |
except StopIteration: | |
return False | |
try: |
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
4 5 | |
5 | |
0 | |
6 | |
8 | |
1 | |
1 | |
0 | |
0 | |
0 |
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
print "\n".join(map(lambda x:((str(x[0]) if x[1]%5 else '') if (x[0]%3) else 'fizz')+('' if (x[1]%5) else 'buzz'),zip(range(1,1001),range(1,1001)))) |
OlderNewer