1
2
3
4
    def isSyncronized(self):
        NO_SYNC = 1
        UNDER_DATE = 2
...

Python nested if blocks

by marcosvanetta, July 25, 2010 01:28, No refactoring, tagged with python, method, metaprogramming

I wanna know if anyone can ...

Avatar Talk
1
2
3
4
#!/usr/bin/env python                                                                                                                                             

from twisted.internet.protocol import ClientCreator, Protocol
...

Python Twisted tcp client

by https://www.google.com/accounts/o8/id?id=AItOawkapZWfDKPlzk45bKWi1klRG7GdRd4leuU, July 01, 2010 07:15, 1 refactoring, tagged with python twisted sockets net

I've an application in twis...

13d35cfcb64d83bd4019053045cd95b4 Talk
1
2
3
4
def get_combinations(sequence,joker=10):
    """
    Checks duplicates in sequence, returns tuple with char and duplicate count
...

Python Poker sequence

by rullon.myopenid.com, May 11, 2010 13:27, No refactoring, tagged with python, poker

get max length of duplicate...

Avatar Talk
1
2
3
4
    def __init__(self, month, day, year):
        if type(month) != int:
            raise NotIntegerError, "month must be an integer"
...

Python Validating argument

by jluebbert.myopenid.com, April 03, 2010 08:08, 4 refactorings, tagged with python, validation, initialization

I'm learning python and I w...

Avatar Talk
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

by rullon.myopenid.com, March 23, 2010 21:19, 1 refactoring, tagged with python, django

When i combine this way, re...

Avatar Talk
1
2
3
4
import re

def process_html(str):
...

Python Regexp extraction in Python

by rullon.myopenid.com, March 17, 2010 10:22, 3 refactorings, tagged with python, regexp

Is it good way to extract p...

Avatar Talk
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

by sergio, February 25, 2010 15:54, 1 refactoring, tagged with python

Considere que, para um dete...

A5f3d249cc5053cdc1eb4ede60fd2f45 Talk
1
2
3
4
from django.db import models

# Create your models here.
...

Python Create a Dict from a Model

by clickpass.com/public/issac.kelly, February 09, 2010 19:20, 2 refactorings, tagged with django

This is a snippet to create...

Avatar Talk
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...

by Tafkas, January 28, 2010 19:53, 5 refactorings, tagged with dates, python, relative position

The function takes an list ...

693a4661eaa71435ce5ebe61de64c5a4 Talk
1
2
3
4
def scale_dates(dates):
    rel_dates = []
    first_day = dates[0]
...

Python Scale data points with the ...

by Tafkas, January 22, 2010 12:55, 3 refactorings, tagged with python, date, timestamp

In order to print a chart t...

693a4661eaa71435ce5ebe61de64c5a4 Talk
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

by Lunis, December 18, 2009 00:12, 5 refactorings, tagged with Prime Numbers, Prime, sieve

I've purposely avoided look...

E683404d3546ca3983e3d68d04506dc1 Talk
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

by arkilus.myopenid.com, December 07, 2009 16:43, 1 refactoring, tagged with lua date clean

Check this in a cleaner way...

Dbe889ac78c192a3f73fdb6da07eae5c Talk
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...

by dominno, December 08, 2009 07:47, No refactoring, tagged with python, metaclass

I need to dynamically creat...

25cf66e4ecb9887c788ef2d13a2f8c16 Talk
1
2
3
4
""" Line-line intersection algorithm """

# vector class from pygame cookbook http://www.pygame.org/wiki/2DVectorClass
...

Python Line-line intersection test

by Mizipzor, December 01, 2009 17:15, 1 refactoring, tagged with python line intersection algorithm math

Line-line intersection algo...

9e9bb40f93094055bd09193eb3bccbb8 Talk
1
2
3
4
def openfile(path):
	global lines
	return open(path).readlines()
...

Python fixcase.py

by Mizipzor, November 16, 2009 16:41, 1 refactoring, tagged with python text parse short

While porting way to many f...

9e9bb40f93094055bd09193eb3bccbb8 Talk
1
2
3
4
#!/usr/bin/env python
import sys, os

...

Python filter by indentation level

by hayalci, September 20, 2009 12:47, 3 refactorings, tagged with indent, filter, shorten

I wrote this to filter outp...

3218c3a378d57a5af5175c4c29dbbf87 Talk
1
2
3
4
def get_conn():
    host="myhost"
    user="myuser"
...

Python MySQLdb database access code

by bennoland.com, July 08, 2009 02:07, 4 refactorings, tagged with database mysql python

I have some database access...

Avatar Talk
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

by sergio, July 10, 2009 19:42, 1 refactoring, tagged with python, math

Equação do segundo graum em...

A5f3d249cc5053cdc1eb4ede60fd2f45 Talk
1
2
3
4
def slug_to_lower(fn):
    """
    Decorator to lowercase string arguments to a function.
...

Python String args to lower decorator

by justinlilly.myopenid.com, June 04, 2009 18:04, 5 refactorings, tagged with python, decorator

This was used to convert Mi...

Avatar Talk
1
2
3
4
[1]

{
...

Python Mapping confobject to objec...

by hyposaurus, June 01, 2009 13:21, 2 refactorings, tagged with loop

I am mapping objects (count...

Avatar Talk
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

by daniop.myopenid.com, May 22, 2009 11:48, 6 refactorings, tagged with svn parsing formatting

This is designed to start a...

Avatar Talk
1
2
3
4
#!/usr/bin/python

from __future__ import division
...

Python Dice Pool Monte Carlo Using...

by matthew.scouten.myopenid.com, February 27, 2009 05:14, 1 refactoring, tagged with dice, monte carlo, generators, iterators

I wanted to calculate the s...

Avatar Talk
1
2
3
4
toLoad = ['one', 'two', 'three']
history = ['two']

...

Python Loading and Unloading elements

by rem7.myopenid.com, February 05, 2009 19:34, 4 refactorings, tagged with python performance

I have to load and unload e...

8339a3712739c903f06b8b9066500a63 Talk
1
2
3
4
import random

INFINITE=1000000000
...

Python Dijkstra to find two points...

by Mizipzor, January 25, 2009 15:43, 1 refactoring, tagged with dijkstra, algorithm, math, path, pathfinding

Discussed on: http://stacko...

9e9bb40f93094055bd09193eb3bccbb8 Talk
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...

by bigsassy.myopenid.com, December 18, 2008 19:06, 4 refactorings, tagged with short, snippet, camelcase, camel case, re, regular expression

Hi, I'm a python newbie. C...

Cc4c514481dbf2cf9f602188dee3c212 Talk