Re: startswith a range

2006-12-25 Thread Jeremy Dunck
On 12/25/06, Jeremy Dunck <[EMAIL PROTECTED]> wrote: I'll have to dig through django source, but I'm pretty sure I've seen sentinels implemented with the "oh, this string'll never be valid input" strategy. I'll make a patch for those. Apparently my comment was grievous slander. I didn't find

Re: startswith a range

2006-12-25 Thread Jeremy Dunck
On 12/25/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote: Jeremy Dunck wrote: > NOT_GIVEN="(*piuhuI&*uyobJH!ikuoi1p9e;mks c0p[p" > > def reduce_(f,s,i=NOT_GIVEN): >it=iter(s) >if i == NOT_GIVEN: hmm. if you post code like that often enough, we may have to revoke your python coder's licen

Re: startswith a range

2006-12-25 Thread Fredrik Lundh
Jeremy Dunck wrote: NOT_GIVEN="(*piuhuI&*uyobJH!ikuoi1p9e;mks c0p[p" def reduce_(f,s,i=NOT_GIVEN): it=iter(s) if i == NOT_GIVEN: hmm. if you post code like that often enough, we may have to revoke your python coder's license ;-) ::: for the archives, here's the "right" way to do i

Re: startswith a range

2006-12-23 Thread Jeremy Dunck
On 12/23/06, Russell Keith-Magee <[EMAIL PROTECTED]> wrote: ... Same result, different composition. Personally, given Guido's predisposition to eliminating reduce() in Python 3000 [1], I'd be avoiding using reduce in new code. A python implementation of reduce: NOT_GIVEN="(*piuhuI&*uyobJH!ik

Re: startswith a range

2006-12-22 Thread Fredrik Lundh
Don Arbow wrote: Python 2.5 has any() and all() to replace reduce(). So I believe you could do this: list = Model.objects.filter(any([Q(name__startswith=letter) for letter in 'abc'])) the goal here isn't to check if any of the Q's are true, it's to join together all the Q's with the "bi

Re: startswith a range

2006-12-22 Thread Don Arbow
On Dec 22, 2006, at 10:21 PM, Russell Keith-Magee wrote: Same result, different composition. Personally, given Guido's predisposition to eliminating reduce() in Python 3000 [1], I'd be avoiding using reduce in new code. Python 2.5 has any() and all() to replace reduce(). So I believe you co

Re: startswith a range

2006-12-22 Thread Kenneth Gonsalves
On 23-Dec-06, at 11:51 AM, Russell Keith-Magee wrote: > Use Q objects to OR three queries together. > > Model.objects.filter(Q(name__startswith='a') | Q (name_startswith='b') > | Q(name_startswith='c')) got this from #django: list=Model.objects.filter(reduce(operator.or_,[Q (name__startwit

Re: startswith a range

2006-12-22 Thread Russell Keith-Magee
On 12/23/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: On 23-Dec-06, at 9:48 AM, Russell Keith-Magee wrote: > Use Q objects to OR three queries together. > > Model.objects.filter(Q(name__startswith='a') | Q(name_startswith='b') > | Q(name_startswith='c')) got this from #django: list=Model

Re: startswith a range

2006-12-22 Thread Kenneth Gonsalves
On 23-Dec-06, at 9:48 AM, Russell Keith-Magee wrote: Use Q objects to OR three queries together. Model.objects.filter(Q(name__startswith='a') | Q(name_startswith='b') | Q(name_startswith='c')) got this from #django: list=Model.objects.filter(reduce(operator.or_,[Q (name__startwith=letter)

Re: startswith a range

2006-12-22 Thread Russell Keith-Magee
On 12/23/06, Kenneth Gonsalves <[EMAIL PROTECTED]> wrote: hi whats the best way of retrieving names that start with either 'a', 'b' or 'c'. I need something like: Model.objects.filter(name__startswith__range('a','c') Use Q objects to OR three queries together. Model.objects.filter(Q(name__

startswith a range

2006-12-22 Thread Kenneth Gonsalves
hi whats the best way of retrieving names that start with either 'a', 'b' or 'c'. I need something like: Model.objects.filter(name__startswith__range('a','c') -- regards kg http://lawgon.livejournal.com http://nrcfosshelpline.in/web/ --~--~-~--~~~---~--~~