http://groups.google.com/group/comp.lang.python/msg/edf12c87...
http://groups.google.com/group/comp.lang.python/msg/43999687...
I would like to ask you , if you get a chance, to explain how the following situation is handled in procedural and functional languages:
If you want to control how an object is represented
when you put it in a template you should define a __str__ method:
class Rep(db.model):
# Properties
...
# Representation
def __str__(self):
return "\n".join(self.replist)
and 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.
Thanks.For instance wikipedia has an example of the same problem written in python as functional or imperative style:
http://en.wikipedia.org/wiki/Functional_programming#Coding_s...
If you're an absolute beginner to programming you should study a bit:
http://learnpythonthehardway.org/
If you've done some programming in the past, you should still study the fundamentals of the language you're using. Buy or borrow a python reference book and read through it. It looks to me like you're getting frustrated with not knowing what return types you're getting out of methods and functions. A reference book will help with that. You should also understand python's way of using duck typing: