1 2 3 4
#!/usr/bin/env python from twisted.internet.protocol import ClientCreator, Protocol ...
Python Twisted tcp client
I've an application in twis...
1 2 3 4
def get_combinations(sequence,joker=10): """ Checks duplicates in sequence, returns tuple with char and duplicate count ...
Python Poker sequence
get max length of duplicate...
1 2 3 4
def __init__(self, month, day, year): if type(month) != int: raise NotIntegerError, "month must be an integer" ...
Python Validating argument
I'm learning python and I w...
1 2 3 4
entries = BlogEntry.objects.filter(status=True,sticky=False,control_tags=controlTag)[offset:(offset+limit)] sticky_entries = BlogEntry.objects.filter(status=True,sticky=True,control_tags=controlTag) ...
Python Django combining querysets
When i combine this way, re...
1 2 3 4
import re def process_html(str): ...
Python Regexp extraction in Python
Is it good way to extract p...
1 2 3 4
numbers = [int(raw_input("enter number: "))] p = lambda x: ((x % 2) and x * 3 + 1) or x / 2 ...
Python algoritmo collatz
Considere que, para um dete...
1 2 3 4
from django.db import models # Create your models here. ...
Python Create a Dict from a Model
This is a snippet to create...
1 2 3 4
def get_pos(rel_dates): """returns the positions of the dates closest to 25%, 50%, and 75%""" pos = [0] # first element ...
Python Return the indexes of speci...
The function takes an list ...
1 2 3 4
def scale_dates(dates): rel_dates = [] first_day = dates[0] ...
Python Scale data points with the ...
In order to print a chart t...
1 2 3 4
def primes(n): s=[1,]+range(4,n+1,2)+range(6,n+1,3)+range(10,n+1,5)+range(14,n+1,7) for x in (2,3,5,7): ...
Python Sieve of Eratosthenes
I've purposely avoided look...
1 2 3 4
class MetaClass(type): def __new__(cls, name, bases, attrs): return super(MetaClass, cls).__new__(cls, name, bases, attrs) ...
Python How to dynamically pass bas...
I need to dynamically creat...
1 2 3 4
function Date:after(otherDate, noHour) return (self.year > otherDate.year or (self.year == otherDate.year and (self.month > otherDate.month or (self.month == otherDate.month and ...
Python LUA 4.0 Date check
Check this in a cleaner way...
1 2 3 4
""" Line-line intersection algorithm """ # vector class from pygame cookbook http://www.pygame.org/wiki/2DVectorClass ...
Python Line-line intersection test
Line-line intersection algo...
1 2 3 4
def openfile(path): global lines return open(path).readlines() ...
Python fixcase.py
While porting way to many f...
1 2 3 4
#!/usr/bin/env python import sys, os ...
Python filter by indentation level
I wrote this to filter outp...
1 2 3 4
#!/usr/bin/python # Criado em:Dom 12/Ago/2007 hs 10:49 # Last Change: Dom 12 Ago 2007 11:11:06 BRT ...
Python equação do segundo grau
Equação do segundo graum em...
1 2 3 4
def get_conn(): host="myhost" user="myuser" ...
Python MySQLdb database access code
I have some database access...
1 2 3 4
def slug_to_lower(fn): """ Decorator to lowercase string arguments to a function. ...
Python String args to lower decorator
This was used to convert Mi...
1 2 3 4
#!/usr/bin/python # show svn log as a summary with revision, username and comment on one line ...
Python Reformat svn log output
This is designed to start a...
1 2 3 4
#!/usr/bin/python from __future__ import division ...
Python Dice Pool Monte Carlo Using...
I wanted to calculate the s...
1 2 3 4
toLoad = ['one', 'two', 'three'] history = ['two'] ...
Python Loading and Unloading elements
I have to load and unload e...
1 2 3 4
import random INFINITE=1000000000 ...
Python Dijkstra to find two points...
Discussed on: http://stacko...
1 2 3 4
def space_out_camel_case(stringAsCamelCase): """Adds spaces to a camel case string. Failure to space out string returns the original string. >>> space_out_camel_case('DMLSServicesOtherBSTextLLC') ...
Python CamelCase to Camel Case (Py...
Hi, I'm a python newbie. C...
I wanna know if anyone can ...