Is there a way to pring a list object in Python?

Benjamin Kaplan benjamin.kaplan at case.edu
Sun Oct 31 15:44:37 EDT 2010


On Sun, Oct 31, 2010 at 3:04 PM, Zeynel <azeynel1 at gmail.com> wrote:
>
>        Rep().replist = L
>        Rep().put()
>        query = Rep.all()
>        for result in query:
>            self.response.out.write(result.replist)
>
> The output of this is:
>
> [u'a', u'b'][u'a', u'b'][u'a', u'b']. . .
>
> So, these are the lists in datastore. I want to take one of these
> lists and apply list method on it. How do I do that? Thanks.
> --

Quite simple. You can apply a list method to a list object by actually
getting the list object. You can't call a list method on a query
object or a Rep object.

Rep() = Rep object
Rep.all() = Query object
list(Rep.all()) = List of Rep objects.
list(Rep.all())[0] = A single Rep object
list(Rep.all())[0].replist = A list

So once you have that last step, you have a list. Which you can
manipulate like any other Python list.
Once you have the list, you can call all them



More information about the Python-list mailing list