On 12/20/06, Fredrik Lundh <[EMAIL PROTECTED]> wrote:
Waylan Limberg wrote:
> Not that we need another way but this would work as well, and it
> doesn't need special cases for one and two item lists but does insert
> the "and" (unlike most of the solutions offered):
>
> def
On 12/20/06, Austin Govella <[EMAIL PROTECTED]> wrote:
Is there an easy way to output that as: "foo, bar, and twinky"
(There are handy functions for this in PHP, ColdFusion, and Rails, but
my Google-fu fails for Python or Django.)
As far as template logic is concerned, I do something similar
Brian Beck wrote:
from django.utils.text import get_text_list
doesn't match the OP's specification for all lists, though:
>>> get_text_list(["one", "two", "three"], 'and')
'one, two and three'
but I guess you could always do
if len(seq) >= 2:
text = get_text_list(seq, ", and")
from django.utils.text import get_text_list
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Django
users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group,
Waylan Limberg wrote:
Not that we need another way but this would work as well, and it
doesn't need special cases for one and two item lists but does insert
the "and" (unlike most of the solutions offered):
def humanize_list(list):
return ", and".join(map(str, ", ".join(map(str,
On 12/20/06, Austin Govella <[EMAIL PROTECTED]> wrote:
Is there an easy way to output that as: "foo, bar, and twinky"
Not that we need another way but this would work as well, and it
doesn't need special cases for one and two item lists but does insert
the "and" (unlike most of the
On 12/20/06, Austin Govella <[EMAIL PROTECTED]> wrote:
I have a list from a queryset:
* foo
* bar
* twinky
Is there an easy way to output that as: "foo, bar, and twinky"
(There are handy functions for this in PHP, ColdFusion, and Rails, but
my Google-fu fails for Python or Django.)
James Aylett wrote:
Is there an easy way to output that as: "foo, bar, and twinky"
If you want to do it in python, use reduce:
--
# l is the list, r is the humanised result
r = reduce(lambda x, y: str(x) + "," + str(y), l)
On Wed, Dec 20, 2006 at 08:27:11AM -0500, Austin Govella wrote:
I have a list from a queryset:
* foo
* bar
* twinky
Is there an easy way to output that as: "foo, bar, and twinky"
If you want to do it in python, use reduce:
I have a list from a queryset:
* foo
* bar
* twinky
Is there an easy way to output that as: "foo, bar, and twinky"
(There are handy functions for this in PHP, ColdFusion, and Rails, but
my Google-fu fails for Python or Django.)
Thanks,
--
Austin Govella
Thinking & Making: IA, UX, and IxD
10 matches
Mail list logo