Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Marko Rauhamaa Newsgroups: comp.lang.python Subject: Re: Why Python 3? Date: Sat, 19 Apr 2014 12:59:18 +0300 Organization: A noiseless patient Spider Lines: 23 Message-ID: <87d2gdej2h.fsf@elektro.pacujo.net> References: <7x8ur1esa5.fsf@ruckus.brouhaha.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Injection-Info: mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="11386"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199QNGFwwm9dIeGvDEVnMqY" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) Cancel-Lock: sha1:K+nIq2Bql8MrVUQ/VBluduhS+Os= sha1:ijDVRvUr8vtzbzO46MnZDVuIIsU= Xref: csiph.com comp.lang.python:70375 Ian Kelly : > On Sat, Apr 19, 2014 at 1:34 AM, Chris Angelico wrote: >> if you're going to move to Python 3, you may as well have your code >> start working that way, so you get used to typing // to divide >> integers and get an integer (floor division). > > [...] > > We also gained a consistent and explicit way to differentiate between > the two different styles of division that classic division > represented, as opposed to picking at run-time based on type. Very often when integer division is needed, so is the remainder. Then, it is good to remember the builtin divmod() function: https://docs.python.org/3.4/library/functions.html#divmod In fact, divmod() goes a long way toward removing the need for // and % in Python code. Marko