How about adding rational fraction to Python?

J. Cliff Dyer jcd at sdf.lonestar.org
Tue Feb 26 08:55:22 EST 2008


On Tue, 2008-02-26 at 04:29 -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. 

Of course.  That's why I think you ought to spell it 3//4.  Nobody gets
confused when a strange operator that they've never seen before does
something unusual.  Average Jo off the street looks at python code and
sees 3/4, and immediately thinks "aha! .75!"  Show the same person 3//4,
and she'll think, "A double slash?  I'd better check the
documentation--or better yet, play with it a little in the interactive
interpreter."






More information about the Python-list mailing list