On Saturday 06 May 2006 04:44, Adrian Holovaty wrote: > Good call! I've changed the docs. For some reason I was thinking a > simple slice would raise KeyError instead of DoesNotExist, but it > does indeed raise DoesNotExist properly.
Ah yes, I hadn't thought about exceptions. I've now fixed a corner case so that it does what the docs say i.e. always raises DoesNotExist for query_set[index] where appropriate. But, thinking about it, perhaps it should actually raise IndexError in this situation, and use DoesNotExist for explicit .get() calls? This would make it act more like other sequences. I don't know how much code this might impact. On a related note, I've realised you can use query_set[:] to do a clone, just like with lists (except it's more like a deep copy, but inexpensive because QuerySets are immutable). I believe there are some bits of code external to the QuerySet class that are using ._clone() -- shall I change them to use the [:] idiom? Luke -- "It is a truth universally acknowledged, that a single man in possession of a good fortune, must be in want of a wife." (Jane Austen) Luke Plant || L.Plant.98 (at) cantab.net || http://lukeplant.me.uk/ --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-developers -~----------~----~----~----~------~----~------~--~---
