date = "%s-%s-%s" % (year, month, i) is exactly what i'd like to do.
The Table object will just be a mysql table, and the filter function will yield a list filtered for those dates. For my purposes the limit variable will not be static, depending on which day of the month it is i will only want it to iterate up to that date in the month (i use 31 here as an example as i would want it to iterate through the 30th of september). Thanks for the input! On Oct 20, 1:21 pm, Larry Bates <[EMAIL PROTECTED]> wrote: > Robocop wrote: > > oops! Sorry about that, i should have just copied my code directly. > > I actually did specify an int in range: > >>> year = '2008' > >>> month = '09' > >>> limit = '31' > >>> for i in range(1,int(limit)): > > > The code is currently failing due to the syntax in the filter, > > particularly the section "date = year'-'month'-'i" > > I believe you want something more like > > date = "%s-%s-%s" % (year, month, i) > > but then again I can't quite figure out what is is that you are wanting to do > (Note: September doesn't have 31 days). > > Where did Table object come from and what does the table.objects.filter method > do and what are the appropriate arguments to that method? If it was "my" > method, and I wanted to use it this way, I would think about changing it so > that > it accepted a filtering function and returned only those objects that passed > the > filtering function: > > def myFilter(obj): > return (obj.date >= '2008-09-01' and obj.date <= '2008-09-30') > > class objects(object): > def __init__(self): > self.objects = [] > > def filter(filterFunc): > return [x for x in self.objects if filterFunc(x)] > > Then > > temp = Table.objects.filter(myFilter) > > temp is a list of objects you can act on. > > -Larry -- http://mail.python.org/mailman/listinfo/python-list