Is there a way to pring a list object in Python?
Zeynel
azeynel1 at gmail.com
Sun Oct 31 15:04:14 EDT 2010
On Oct 31, 5:52 am, Dave Angel <da... at ieee.org> wrote:
> On 2:59 PM, Zeynel wrote:> class Rep(db.Model):
> > author = db.UserProperty()
> > replist = db.ListProperty(str)
> > unique = db.ListProperty(str)
> > date = db.DateTimeProperty(auto_now_add=True)
>
> > ....
>
> > Rep().replist = L
> > Rep().put()
> > mylist = Rep().all().fetch(10)
>
> > I am trying to display mylist; but I am getting the object. Thanks.
>
> I don't know any meaning for "pring."
>
> Care to mention what db is? Presumably it's some other module, not in
> the standard library, that you've imported. And presumably it has a
> class called Model defined in it.
>
> But the three lines following make no sense to me in isolation, so
> unless you know how db.Model is intended to be used, I can't imagine
> what you expect here. Rep().replist = L creates a temporary object,
> gives it an attribute, and throws them both away. Although I could
> write code that would have enough side effects to do something with
> that, I can't imagine why I would want to.
>
> Be more explicit with the assumptions (in this case, at least show the
> import), and with the results. So instead of saying "I am getting the
> object," say
>
> print mylist
>
> produces the output:
>
> sjfdsljdsfds;lkjfdsfds
> fdsljfds;ldsj;dslkjfds
> dsfjlfkjslkjfd s fj lkjfd
>
> DaveA
I am using Google App Engine, but it seems that the problem is a
Python problem. I fixed the code a little bit, now I can print the
lists:
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.
More information about the Python-list
mailing list