See how a minor change to your commit message style can make you a better programmer.
Format: <type>(<scope>): <subject>
<scope>
is optional
def match_format_string(format_str, s): | |
""" https://stackoverflow.com/questions/10663093/use-python-format-string-in-reverse-for-parsing | |
Match s against the given format string, return dict of matches. | |
We assume all of the arguments in format string are named keyword arguments (i.e. no {} or | |
{:0.2f}). We also assume that all chars are allowed in each keyword argument, so separators | |
need to be present which aren't present in the keyword arguments (i.e. '{one}{two}' won't work | |
reliably as a format string but '{one}-{two}' will if the hyphen isn't used in {one} or {two}). | |
We raise if the format string does not match s. |
inputs = [0, 1, 0, 0] | |
weights = [0, 0, 0, 0] | |
desired_result = 1 | |
learning_rate = 0.2 | |
trials = 6 | |
def evaluate_neural_network(input_array, weight_array): | |
result = 0 | |
for i in range(len(input_array)): | |
layer_value = input_array[i] * weight_array[i] |
""" | |
Code to write data read from a URL to a file | |
Based on an answer on SO: | |
http://stackoverflow.com/questions/22676/how-do-i-download-a-file-over-http-using-python/22721 | |
""" | |
import urllib2 | |
mp3file = urllib2.urlopen("http://www.example.com/songs/mp3.mp3") |
from sqlalchemy.ext.declarative import declarative_base | |
from sqlalchemy import create_engine | |
from sqlalchemy import Column, Integer, String | |
from sqlalchemy.orm import sessionmaker | |
from sqlalchemy import ForeignKey | |
from sqlalchemy.orm import relationship, backref | |
from kivy.graphics import Rectangle | |
from kivy.uix.boxlayout import BoxLayout | |
from kivy.uix.label import Label | |
from kivy.uix.widget import Widget |
#!/usr/bin/env python | |
# liuw | |
# Nasty hack to raise exception for other threads | |
import ctypes # Calm down, this has become standard library since 2.5 | |
import threading | |
import time | |
NULL = 0 |