How about adding rational fraction to Python?

Marc 'BlackJack' Rintsch bj_666 at gmx.net
Tue Feb 26 09:33:35 EST 2008


On Tue, 26 Feb 2008 04:29:18 -0800, Lie wrote:

>> J Cliff Dyer:
>> I'm in the camp that believes that 3/4 does indeed yield the integer 0,
>> but should be spelled 3//4 when that is the intention.
> 
> That's creepy for people that are new to programming and doesn't know
> how CPUs work and are used to general mathematics. That means most
> people. As programming language are now more accessible to regular
> people without specialized Computer Science degree, it is a just
> natural trend that computer arithmetic must be done in an expectable
> manner as seen by those general population not by people who holds a
> CS degree.

So why is it creepy then!?  ``3 // 4`` is for the people knowing about
integer division and ``3 / 4`` gives the expected result for those who
don't.  Those who don't know ``//`` can write ``int(3 / 4)`` to get the
same effect.

Ciao,
	Marc 'BlackJack' Rintsch



More information about the Python-list mailing list