you are right!
lol, trapped myself nicely ... happens when you dont think :-)

thx

wolfram

On Dec 4, 2007 3:57 PM, Luke Plant <[EMAIL PROTECTED]> wrote:
>
> On Tuesday 04 December 2007 14:41:07 Wolfram Kriesing wrote:
> > another thing i jsut ran into:
> >
> > this causes an IndexError
> >       Model.objects.filter(something)[0]
> > you have to add the colon before the 0
> >       Model.objects.filter(something)[:0]
> > the limit(0) would not bring this error, it would not let
> > first-time-users run into this problem
>
> I'm not sure why [:0], would ever be useful -- it always returns an
> empty list, right?  Did you mean [:1] ? But anyway, the behaviour here
> is exactly consistent with python lists:
>
> >>> [][0]
> Traceback (most recent call last):
>   File "<stdin>", line 1, in <module>
> IndexError: list index out of range
> >>> [][:0]
> []
> >>> [][:1]
> []
>
>
> We are not helping newbies by making slicing for QuerySets work
> differently -- in fact we've gone to some length to make sure it
> behaves as analogously as possible -- it throws the same exceptions
> etc.
>
> Luke
>
> --
> "My capacity for happiness you could fit into a matchbox without taking
> out the matches first." (Marvin the paranoid android)
>
> Luke Plant || http://lukeplant.me.uk/
>
> >
>



-- 
cu

Wolfram

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to