Google Groups Home
Help | Sign in
Message from discussion Comments regarding QuerySet.valuelist()
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Gary Wilson  
View profile
 More options Nov 4 2006, 11:34 pm
From: "Gary Wilson" <gary.wil...@gmail.com>
Date: Sun, 05 Nov 2006 04:34:42 -0000
Local: Sat, Nov 4 2006 11:34 pm
Subject: Re: Comments regarding QuerySet.valuelist()

> No, I think you're right that we should have a mechanism in place for
> ensuring that methods like this always return results of a consistent
> type. I'm not sure whether it'd be better to do two methods or to
> return singleton tuples, though; anybody got thoughts one way or
> another?

Well, a lot of times, I see myself needing just a simple list (list of
titles, list of id's to pass to in_bulk(), etc.)  If we just had a
function that returned tuples, then a list comprehension would still
have to be used to make a list from the singleton tuples when wanting a
for loop or for passing to in_bulk().

With adding both methods, we then have a method for returning each of
the main python data structures.  As for valuelist(), instead of being
able to only pass a single parameter, it might be cool to make a zip'ed
list of values, i.e.

>>> list(qset.valuelist("a","b"))

[a1, b1, a2, b2, ...]

    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google