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 [2]: e = 3 | |
In [3]: x = {} | |
In [4]: try: | |
...: x['a'] | |
...: except Exception as e: | |
...: 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
>>> AssertionError = ValueError | |
>>> assert False, "Assert Failed!" | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ValueError: Assert Failed! | |
>>> AssertionError = None | |
>>> assert False, "Assert Failed!" | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
TypeError: 'NoneType' object is not callable |
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 [2]: x = 3 | |
In [3]: def foo(): | |
...: global x | |
...: def x(): | |
...: pass | |
...: | |
In [4]: x | |
Out[4]: 3 |
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 zipline.gens import stateful_transform | |
from zipline.finance.trading import TransactionSimulator | |
from zipline.finance.performance import PerformanceTracker | |
def trade_simulation_client(stream_in, algo, environment, sim_style): | |
""" | |
Generator that takes the expected output of a merge, a user | |
algorithm, a trading environment, and a simulator style as | |
arguments. Pipes the merge stream through a TransactionSimulator | |
and a PerformanceTracker, which keep track of the current state of |
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 zipline.gens import stateful_transform | |
from zipline.finance.trading import TransactionSimulator | |
from zipline.finance.performance import PerformanceTracker | |
def trade_simulation_client(stream_in, algo, environment, sim_style): | |
#============ | |
# Algo Setup | |
#============ |
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
Flavors of queues in Qexec system topology: | |
|| Queue type: || Receives new tasks from: || Routes tasks to: || | |
-------------------------------------------------------------------------------------------------------------- | |
|| LQueue || http PUT requests (via WSGI app) || RQueue (via ZMQ socket) || | |
|| RQueue || polls an LQueue for new tasks (via ZMQ socket) || Arbiter instances (via gevent queues)|| | |
|| MQueue || http PUT requests (via WSGI app) || Arbiter instances (via gevent queues)|| | |
Flavors of servers: |
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
#Midpoint for zmq node chain test. Receives a message | |
#via SUB socket, then propagates that message out via | |
#PUB socket to sink nodes. | |
import zmq | |
context = zmq.Context() | |
receiver = context.socket(zmq.SUB) | |
receiver.connect("tcp://localhost:5555") |
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 outer(): | |
... def inner(): | |
"Fails with SyntaxError" | |
... from numpy import * | |
... return array | |
... return inner() | |
... | |
<stdin>:2: SyntaxWarning: import * only allowed at module level | |
File "<stdin>", line 3 | |
SyntaxError: import * is not allowed in function 'inner' because it is a nested function |
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 gc | |
import objgraph | |
class Foo(object): | |
def __init__(self): | |
self._gen = None | |
def __iter__(self): | |
self._gen = self.gen() |
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
# Run flake8 against any added/modified python files in the current git repo. | |
function check8 () | |
{ | |
errors=`git diff --relative --name-only --diff-filter AM --ignore-submodules | grep -e "\.py" | xargs flake8` | |
retval=$? | |
# xargs returns 127 if flake8 couldn't be found | |
if [ "$retval" = "127" ] | |
then |