% is not an operator [was Re: Verbose and flexible args and kwargs syntax]

Ian Kelly ian.g.kelly at gmail.com
Wed Dec 14 10:45:04 EST 2011


On Wed, Dec 14, 2011 at 6:29 AM, Eelco <hoogendoorn.eelco at gmail.com> wrote:
> On Dec 14, 1:38 pm, Steven D'Aprano <steve
> +comp.lang.pyt... at pearwood.info> wrote:
>> On Wed, 14 Dec 2011 02:09:32 -0800, Eelco wrote:
>> > Arguably, the most elegant thing to do is to define integer division and
>> > remainder as a single operation; which is not only the logical thing to
>> > do mathematically, but might work really well programmatically too.
>>
>> > The semantics of python dont really allow for this though. One could
>> > have:
>>
>> > d, r = a // b
>>
>> That would be:
>>
>> >>> divmod(17, 5)
>>
>> (3, 2)
>
> Cool; if only it were in the math module id be totally happy.

Probably it's not in math because it's not a thin wrapper around a C
math library function, which is how the module was conceived.  There
are already some exceptions in the math module, but I think they are
all newer than divmod.



More information about the Python-list mailing list