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 humanize_list(list): > return ", and".join(map(str, ", ".join(map(str, list)).rsplit(',',1))) >>> humanize_list(["one", "two"]) 'one, and two'
Ahh, right, when I whipped that up, I wasn't including a comma with the and, but before posting I reread the original email and saw the comma was included in the request so I just stuck it in there without further testing. Personally, I would just pull that comma out (the first comma in line 2), which gives us the same result as django.utils.text.get_text_list. -- ---- Waylan Limberg [EMAIL PROTECTED] --~--~---------~--~----~------------~-------~--~----~ 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, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---