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) > But it wouldnt work that well in composite expressions; selecting the > right tuple index would be messy and a more verbose form would be > preferred. However, performance-wise its also clearly the best solution, > as one often needs both output arguments and computing them > simultaniously is most efficient. Premature optimization. -- Steven -- http://mail.python.org/mailman/listinfo/python-list