1 > 0 == True -> False

Ian Kelly ian.g.kelly at gmail.com
Thu Jan 30 16:17:24 EST 2014


On Jan 30, 2014 1:40 PM, "Chris Angelico" <rosuav at gmail.com> wrote:
>
> On Fri, Jan 31, 2014 at 7:28 AM, Ian Kelly <ian.g.kelly at 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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140130/e10a4121/attachment.html>


More information about the Python-list mailing list