Skip to content

Instantly share code, notes, and snippets.

class ConfigInfo(object):
rootDir = "/home/jpmcgrady/workspace"
subDir = "src"
class GrepDict(object):
def __init__(self, projName, findMe):
self.config = ConfigInfo
self.projName = projName
self.findMe = findMe
class dictWrap(object):
def __init__(self, dictIn = False, fnXform = False):
self.noneVal = None
if dictIn:
if fnXform:
dictIn = dict((k,fnXform(v)) for k,v in dictIn.items())
self.__dict__.update(dictIn)
def __getattribute__(self, attr):
try:
return object.__getattribute__(self, attr)
listA = [1,2,3,4] #listA now holds a refrence to a list object
listB = listA #a refrence to the refrence held by listA
listC = list(listA) #a new copy of the object reffered to in the refrence held by listA
listA.append('dog') #update the object reffered to in the refrence held by listA
print(listB) #a refrence to the refrence held by listA -> the object reffered to in the refrence held by listA
print(listC) #the copy we made before updating is, of course, unchanged
#!/usr/bin/env python
from Queue import Queue
from threading import Thread
from urllib2 import urlopen
from time import time
from random import shuffle
hosts = ["yahoo.com", "google.com", "amazon.com","ibm.com", "apple.com",
"bbc.co.uk", "npr.org", "cnn.com", "ubuntu.com", "soundcloud.com",
"bogus.url",'ebay.com','linux.org','osuosl.org','renren.com','alibaba.com',
class myStr(str):
def pogoCase(self,jumpInt):
return "".join([myCar.lower() if myInt % jumpInt else myCar.upper() for myInt, myCar in enumerate(self)])
thisThing = myStr("The quick brown fox jumped over the lazy dog.")
print thisThing
print thisThing.pogoCase(3)
print thisThing.pogoCase(2)
print type(thisThing) is str
"""easy string compression, based on the old compressed bitmap"""
class listComp(object):
@staticmethod
def compactLst(lstIn, lastOne = ''):
if lastOne == '':
listComp.myList = []
if lstIn[0] != lastOne:
#start a new acumulator