pluralize : empty dict is plural

5 views
Skip to first unread message

EuGeNe

unread,
Jun 3, 2008, 6:21:18 AM6/3/08
to Django users
I am not sure whether this is a bug or a feature, an empty dict is
plural?

>>> from django.template import Template, Context
>>> t = Template("{{ d|pluralize }}")
>>> empty = Context({"d" : dict()})
>>> t.render(empty)
u's'
>>> one = Context({"d" : dict(a=1)})
>>> t.render(one)
u''
>>> two = Context({"d" : dict(a=1, b=2)})
>>> t.render(two)
u's'

EuGeNe -- http://www.3kwa.com

Russell Keith-Magee

unread,
Jun 3, 2008, 6:39:41 AM6/3/08
to django...@googlegroups.com
On Tue, Jun 3, 2008 at 6:21 PM, EuGeNe <eugene.va...@gmail.com> wrote:
>
> I am not sure whether this is a bug or a feature, an empty dict is
> plural?

Feature.

If I'm counting bags, I have:
0 Bags
1 Bag
2 Bags
3 Bags

The 0-case is given the plural name; None/{} etc is a 0-case.

Yours,
Russ Magee %-)

Eugene Van den Bulke

unread,
Jun 3, 2008, 8:16:44 AM6/3/08
to django...@googlegroups.com
On Tue, Jun 3, 2008 at 12:39 PM, Russell Keith-Magee <freakb...@gmail.com> wrote:
> I am not sure whether this is a bug or a feature, an empty dict is
> plural?

Feature.

If I'm counting bags, I have:
0 Bags
1 Bag
2 Bags
3 Bags

argh ... I am sprung ... not a native English speaker :P

Thanks

EuGeNe -- http://www.3kwa.com

Reply all
Reply to author
Forward
0 new messages