A "Best of the Best Practices" (BOBP) guide to developing in Python.
- "Build tools for others that you want to be built for you." - Kenneth Reitz
- "Simplicity is alway better than functionality." - Pieter Hintjens
| import Queue | |
| import threading | |
| class WorkerThread(threading.Thread): | |
| def __init__(self, q): | |
| super(WorkerThread, self).__init__() | |
| self q = q | |
| self.exception = None | |
| #!/bin/bash | |
| # Thanks goes to @pete-otaqui for the initial gist: | |
| # https://gist.github.com/pete-otaqui/4188238 | |
| # | |
| # Original version modified by Marek Suscak | |
| # | |
| # works with a file called VERSION in the current directory, | |
| # the contents of which should be a semantic version number | |
| # such as "1.2.3" or even "1.2.3-beta+001.ab" |
| <form method="post" action=""> | |
| {{ form.name}} | |
| {{ form.hidden_tag() }} | |
| <br/> | |
| {% for entry in form.hours %} | |
| {{ loop.index0|dow }} | |
| {{ entry() }} | |
| {% endfor %} | |
| <input type="submit"/> | |
| </form> |
| #!/usr/bin/env python | |
| # -*- coding: utf-8 -*- | |
| # Python 3 and compatibility with Python 2 | |
| from __future__ import unicode_literals, print_function | |
| import os | |
| import sys | |
| import re | |
| import logging |
| ##Python 2 | |
| #import urllib | |
| #url = "https://www.cs.cmu.edu/~./enron/enron_mail_20150507.tgz" | |
| #urllib.urlretrieve(url, filename="../enron_mail_20150507.tgz") | |
| #print "download complete!" | |
| ##Python 3 | |
| import urllib.request | |
| url = "https://www.cs.cmu.edu/~./enron/enron_mail_20150507.tgz" | |
| print ("download start!") |
| #!/usr/bin/python3 | |
| """ Demonstrating APScheduler feature for small Flask App. """ | |
| from apscheduler.schedulers.background import BackgroundScheduler | |
| from flask import Flask | |
| def sensor(): | |
| """ Function for test purposes. """ | |
| print("Scheduler is alive!") |
| # -*- coding: utf-8 -*- | |
| import logging | |
| import os | |
| import datetime | |
| import time | |
| class SingletonType(type): | |
| _instances = {} |
| ''' | |
| testing celery progress reporting/polling | |
| * start server | |
| python tempserver.py | |
| * start worker | |
| celery -A tempserver.celery worker -c 1 --loglevel=DEBUG | |
| * browse to localhost:5000/ | |
| ''' | |
| from flask import Flask, request, render_template_string |
| #!/bin/bash | |
| # Thanks goes to @pete-otaqui for the initial gist: | |
| # https://gist.github.com/pete-otaqui/4188238 | |
| # | |
| # Original version modified by Marek Suscak | |
| # | |
| # works with a file called VERSION in the current directory, | |
| # the contents of which should be a semantic version number | |
| # such as "1.2.3" or even "1.2.3-beta+001.ab" |