On Jan 30, 2014 1:40 PM, "Chris Angelico" <ros...@gmail.com> wrote:
>
> On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly <ian.g.ke...@gmail.com> wrote:
> > Of course if you're at all concerned about i18n then the proper way to
> > do it would be:
> >
> > ngettext("You have scored %d point", "You have scored %d points",
score) % score
>
> Ugh, so much duplication! We can totally do better than that.
>
> ngettext(*(lambda x,s: (x,x+'s',s))("You have scored %d point",score))
>
> Much better!
>
>
> Incidentally, in creating the above abomination, I found that I can't do
this:
>
> >>> print(*(lambda x: (x,x+'s'))("You have scored %d point"),score)
> SyntaxError: only named arguments may follow *expression
>
> But I can do this:
>
> >>> print(score,*(lambda x: (x,x+'s'))("You have scored %d point"))
> 1 You have scored %d point You have scored %d points
>
> Why is tuple unpacking limited to the last argument? Is it just for
> the parallel with the function definition, where anything following it
> is keyword-only?

Lack of a convincing use case, and the position of the following arguments
would then be dependent upon the length of the tuple, which in many cases
could result in subtle bugs.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to