Jeff Spaleta wrote:
On Fri, May 1, 2009 at 1:02 PM, Ignacio Vazquez-Abrams
> The value or callable passed to the constructor sets it.
Should we just cobble together a pure python subclass that mimics this
behavior to use as a drop in replacement for the missing defaultdict?
Jef's found some code for defaultdict with a suitable license. We'll
put it in python-fedora for now and look at spinning out a compat
library if there's more problems. Between that and the
python-sqlalchemy update from:
he seems to have all the EL-5 specific errors ironed out.
kylev noticed some additional problems that are not related to python-2.4.
* There's lots of methods defined with default arguments like this:
component(self, start='1990-01-01', end=time.strftime("%Y-%m-%d"),
Default arguments are evaluated when the method is created. This means
there's two problems with this code:
1) The time.strftime() is only going to be run once, when the program
starts instead of every time the method is called (which is probably
2) The list created for status will be reused every time the method is
called so it will only be a fresh, empty list the first time through.
To solve these, use something like this:
def component(self, start='1990-01-01', end=None,
end = end or time.strftime("%Y-%m-%d")
status = status or 
* This code would be clearer if rewritten:
if str(status) == status: status = [status]
instead do this:
if isinstance(status, str):
status = [status]
* Code like this:
are going to fail at some point. They assume that the list returned
by .keys() will always put the keys in the same order. This is not
guaranteed and adding and taking away other values in the dictionary can
change the key at position k.