This link has been bookmarked by 173 people . It was first bookmarked on 09 Jul 2006, by craig hancock.
-
03 Jan 16
-
03 Nov 10
-
12 Oct 10
-
04 Oct 10
-
08 Aug 10
-
04 Aug 10
-
02 Aug 10
-
21 Jul 10
-
13 Jul 10
-
10 Jul 10
-
23 Jun 10
fs41 .What design patterns are applicable to Python? Some patterns are an intrinsic part of Python, other patterns require some careful coding to get the best from them. What new patterns appear in Python?
-
12 May 10
-
11 May 10
-
Small Boy with a Patterns Book
After spending a bunch of time thinking about these ideas, over a few days now, I finally recognized in myself what I call "Small Boy with a Patterns Book". You can always tell when someone on your team is reading the Gang of Four book (Gamma, et al., Design Patterns). Every day or so, this person comes in with a great idea for a place in the system that is just crying out for the use of Composite, or whatever chapter he read last night.
-
A more significant drawback of singleton is that it breaks testing. Unit tests often work by creating mock objects that look similar to real objects but have dummy implementations. If your code has built brick walls protecting that 'database' instance, then it becomes harder, or even impossible to temporarily stub it out (although very little is completely impossible in Python). Test driven development very quickly leads you to abandon large singletons.
-
-
10 May 10
-
09 May 10
-
08 May 10
-
07 May 10
-
27 Apr 10
-
26 Apr 10
-
24 Apr 10
-
14 Mar 10
-
15 Feb 10
-
20 Jan 10
-
15 Jan 10
-
28 Dec 09
-
05 Dec 09
-
20 Oct 09
-
17 Sep 09
-
10 Sep 09
Alec Schueler"A design pattern describes a problem that occurs over and again and the core of a solution to that problem in such a way that it may be used in many different ways...Recognising when the same technique is being used in a different context allows us to ap
-
28 Aug 09
zstumgorenWhat design patterns are applicable to Python? Some patterns are an intrinsic part of Python, other patterns require some careful coding to get the best from them. What new patterns appear in Python?
-
27 Aug 09
-
28 Jul 09
-
14 Jul 09
-
15 Jun 09
-
14 Jun 09
-
13 Jun 09
-
10 Jun 09
-
02 Jun 09
-
17 May 09
-
13 May 09
-
29 Apr 09
-
09 Apr 09
-
20 Feb 09
-
13 Feb 09
-
09 Feb 09
golimpioWhat design patterns are applicable to Python? Some patterns are an intrinsic part of Python, other patterns require some careful coding to get the best from them. What new patterns appear in Python?
-
08 Feb 09
Matteo BertiniWhat design patterns are applicable to Python? Some patterns are an intrinsic part of Python, other patterns require some careful coding to get the best from them. What new patterns appear in Python?
-
05 Feb 09
-
03 Feb 09
-
01 Feb 09
-
31 Jan 09
-
30 Jan 09
-
23 Dec 08
-
22 Oct 08
-
29 Aug 08
-
07 Jul 08
-
class Delegate: '''Handles a list of methods and functions Usage: d = Delegate() d += function # Add function to end of delegate list d(*args, **kw) # Call all functions, returns a list of results d -= function # Removes last matching function from list d -= object # Removes all methods of object from list ''' def __init__(self): self.__delegates = [] def __iadd__(self, callback): self.__delegates.append(callback) return self def __isub__(self, callback): # If callback is a class instance, # remove all callbacks for that instance self.__delegates = [ cb for cb in self.__delegates if getattr(cb, 'im_self', None) != callback] # If callback is callable, remove the last # matching callback if callable(callback): for i in range(len(self.__delegates)-1, -1, -1): if self.__delegates[i] == callback: del self.__delegates[i] return self return self def __call__(self, *args, **kw): return [ callback(*args, **kw) for callback in self.__delegates]
-
class Event(property): '''Class event notifier Usage: class C: TheEvent = Event() def OnTheEvent(self): self.TheEvent(self, context) instance = C() instance.TheEvent += callback instance.OnTheEvent() instance.TheEvent -= callback ''' def __init__(self): self.attrName = attrName = "__Event_" + str(id(self)) def getEvent(subject): if not hasattr(subject, attrName): setattr(subject, attrName, Delegate()) return getattr(subject, attrName) super(Event, self).__init__(getEvent) def call(self, subject, *args, **kw): if hasattr(subject, self.attrName): getattr(subject, self.attrName)(subject, *args, **kw)
-
- count([n])
- Return consecutive integers starting with n
- ifilter(predicate, iterable)
- Return all elements x of iterable for which predicate(x) is true.
- imap(function, *iterables)
- Like map(), but returns an iterator rather than a list.
- izip(*iterables)
- Like zip(), except it returns an iterator.
- repeat(obj)
- Returns an iterator that yields obj an unlimited number of times.
- times(n, [object])
- Returns object a total of n times.
-
save = result.append while somecondition: save(calculateValue())
-
-
27 Jun 08
-
10 May 08
-
04 Apr 08
-
08 Jan 08
-
06 Dec 07
-
06 Sep 07
-
15 Jun 07
-
06 Mar 07
-
23 Jan 07
-
09 Jan 07
-
19 Dec 06
-
25 Oct 06
-
16 Oct 06
-
04 Oct 06
chris-4x4What design patterns are applicable to Python? Some patterns are an intrinsic part of Python, other patterns require some careful coding to get the best from them. What new patterns appear in Python?
-
22 Sep 06
-
02 Aug 06
-
28 Jul 06
-
09 Jul 06
-
15 Jun 06
-
24 Apr 06
-
05 Apr 06
-
01 Apr 06
Would you like to comment?
Join Diigo for a free account, or sign in if you are already a member.