4 ms·
I don't know enough of neither to give you a good answer. But there were two solutions to my question in Python group that helped me understand the issue: http
by zeynel1 16y ago
I don't know enough of neither to give you a good answer. But there were two solutions to my question in Python group that helped me understand the issue:
http://groups.google.com/group/comp.lang.python/msg/edf12c874e7b2733?hl=en http://groups.google.com/group/comp.lang.python/msg/edf12c87...
http://groups.google.com/group/comp.lang.python/msg/439996871519514e?hl=en 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.
- po 16y agoPython can be used to write procedural, functional or OOP. It's a multi-paradigm language which means it's up to you to give the code the structure you think is best for the problem. 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_styles 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/ 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: http://en.wikipedia.org/wiki/Duck_typing#In_Python http://en.wikipedia.org/wiki/Duck_typing#In_Python