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
| # 2.7 | |
| if (tstate->recursion_depth > recursion_limit) { | |
| --tstate->recursion_depth; | |
| PyErr_Format(PyExc_RuntimeError, | |
| "maximum recursion depth exceeded%s", | |
| where); | |
| return -1; | |
| # 3.4 |
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
| def write_block(names, next_name, f): | |
| for depth, func_name in enumerate(names): | |
| f.write("\n" + " " * depth + "def %s():" % func_name) | |
| f.write("\n" + " " * (depth + 1) + "%s()" % next_name) | |
| for depth, func_name in reversed(list(enumerate(names[1:]))): | |
| f.write("\n" + " " * (depth + 1) + "%s()" % func_name) | |
| f.write("\n") # for readability ;) | |
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
| def write_chained_functions(total_functions): | |
| with open('/usr/share/dict/words','r') as name_file: | |
| fn_names = [line.strip() for line in name_file.readlines()] | |
| first_name = fn_names[0] | |
| last_name = fn_names[total_functions] | |
| fn_names = iter(fn_names) | |
| with open("empty_chain.py", 'w') as f: | |
| name = next(fn_names) | |
| following_name = next(fn_names) | |
| for _ in range(total_functions): |
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
| byterun_env ⚲ type python | |
| python is /usr/local/bin/python | |
| byterun_env ⚲ source bin/activate | |
| (byterun_env)byterun_env ⚲ type python | |
| python is /Users/afk/Dropbox/python/byterun_env/bin/python | |
| (byterun_env)byterun_env ⚲ python | |
| Python 2.7.6 (default, Feb 11 2014, 18:46:41) | |
| [GCC 4.2.1 Compatible Apple LLVM 4.2 (clang-425.0.28)] on darwin | |
| Type "help", "copyright", "credits" or "license" for more information. | |
| >>> |
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
| ################################################################################ | |
| ### namedtuple | |
| ################################################################################ | |
| _class_template = '''\ | |
| class {typename}(tuple): | |
| '{typename}({arg_list})' | |
| __slots__ = () |
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
| FAIL: test_generator_from_generator2 (tests.test_functions.TestGenerators) | |
| ---------------------------------------------------------------------- | |
| Traceback (most recent call last): | |
| File "/Users/afk/Dropbox/python/byterun_env/byterun/tests/test_functions.py", line 239, in test_generator_from_generator2 | |
| """) | |
| File "/Users/afk/Dropbox/python/byterun_env/byterun/tests/vmtest.py", line 86, in assert_ok | |
| self.assert_same_exception(vm_exc, py_exc) | |
| File "/Users/afk/Dropbox/python/byterun_env/byterun/tests/vmtest.py", line 96, in assert_same_exception | |
| self.assertEqual(str(e1), str(e2)) | |
| nose.proxy.AssertionError: AssertionError: "unsupported operand type(s) for *: 'NoneType' and 'NoneType'" != '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
| >>> class Test(object): | |
| ... var = 7 | |
| ... def __init__(self): | |
| ... self.ivar = 2 | |
| ... | |
| >>> t = Test() | |
| >>> s = Test() | |
| >>> t.__dict__ | |
| {'ivar': 2} | |
| >>> t.var |
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 Thing(object): | |
| ... def __init__(self, name, description): | |
| ... self.name = name | |
| ... self.desc = description | |
| ... | |
| >>> b = Thing('box', 'empty') | |
| >>> c = Thing('cat', 'fuzzy') | |
| >>> collection = {'box': b, 'cat' : c} | |
| >>> collection['box'] | |
| <__main__.Thing object at 0x1073a2150> |
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 FalseContext(object): | |
| ... def __enter__(self): | |
| ... l.append('i') | |
| ... return self | |
| ... def __exit__(self, exc_type, exc_val, exc_tb): | |
| ... l.append('o') | |
| ... return False | |
| ... | |
| >>> class TrueContext(object): | |
| ... def __enter__(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
| (byterun_env)byterun [assorted-fixes $%] ⚲ tox -- tests.test_basic:TestIt | |
| GLOB sdist-make: /Users/afk/Dropbox/python/byterun_env/byterun/setup.py | |
| py27 inst-nodeps: /Users/afk/Dropbox/python/byterun_env/byterun/.tox/dist/Byterun-1.0.zip | |
| py27 runtests: commands[0] | nosetests tests.test_basic:TestIt | |
| .......................... | |
| ---------------------------------------------------------------------- | |
| Ran 26 tests in 0.280s | |
| OK | |
| py33 inst-nodeps: /Users/afk/Dropbox/python/byterun_env/byterun/.tox/dist/Byterun-1.0.zip |