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 multiprocessing import Pool | |
def calculate(number): | |
return number | |
if __name__ == '__main__': | |
pool = Pool() | |
result = pool.map(calculate, range(4)) |
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 concurrent.futures import ProcessPoolExecutor | |
def calculate(number): | |
return number | |
with ProcessPoolExecutor() as executor: | |
result = executor.map(calculate, range(4)) |
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
You can write the threaded example as: | |
import concurrent.futures | |
import itertools | |
import random | |
def generate_random(count): | |
return [random.random() for _ in range(count)] | |
if __name__ == "__main__": | |
with concurrent.futures.ThreadPoolExecutor(max_workers=2) as executor: |
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
set cut_paste_input [stack 0] | |
version 8.0 v6 | |
push $cut_paste_input | |
NoOp { | |
name NoOp2 | |
selected true | |
xpos 824 | |
ypos -172 | |
addUserKnob {20 User} | |
addUserKnob {12 pixelCoordinate} |
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 kivy.app import App | |
# kivy.require("1.8.0") | |
from kivy.uix.label import Label | |
class SimpleKivy(App): | |
def build(self): | |
return Label() | |
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
class Book(object): | |
def __init__(self,title, author): | |
self.title = title | |
self.author = author | |
print self.__dict__ | |
def __iter__(self): | |
for each in self.__dict__.keys(): | |
yield self.__getattribute__(each) |
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
[loggers] | |
keys=root | |
[handlers] | |
keys=consoleHandler | |
[formatters] | |
keys=simpleFormatter | |
[logger_root] |
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
#The "loggers" section contains the key names for all the loggers in this | |
#configuration. These are not the actual channel names, but values used to | |
#identify where the parameters for each logger are found in this file. | |
#The section for an individual logger is named "logger_xxx" where the "key" | |
#for a logger is "xxx". So ... "logger_root", "logger_appName", etc | |
#Logger key names can be any identifier, except "root" which is reserved for | |
#the root logger. (The names "lognn" are generated by the GUI configurator.) | |
[loggers] | |
keys=root, appName |
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 time | |
def loop_query(fn, offset=0): | |
""" Decorator to make a few attempts before failing on query in db | |
Args: | |
func (function): Function holding the query | |
Kwargs: | |
offset(float): Offset to desynchronize the query |
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 collections as _collections | |
Point = _collections.namedtuple("Point", ("x", "y", "z")) | |
# print help(_collections.namedtuple) | |
class PointLocation(object): | |
def __init__(self, x, y, z): | |
self._x = x | |
self._y = y |