How about adding rational fraction to Python?

Paul Rubin http
Wed Feb 27 22:00:19 EST 2008


Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au> writes:
> Okay, that's just insane, making distinctions between literals and 
> variables like that.
> 
> 1 + 1.0  # okay

=> Yes

> x = 1
> x + 1.0  # is this okay or not? who knows?

=> Yes, ok

> len('s') + 1.0  # forbidden

Yes, forbidden.  

More examples:

   x = 1
   y = len(s) + x

=> ok, decides that x is an int

   x = 1
   y = x + 3.0

=> ok, decides that x is a float

   x = 1
   y = x + 3.0
   z = len(s) + x

=> forbidden, x cannot be an int and float at the same time.

> I am so glad you're not the designer of Python.

This is how Haskell works and I don't notice much complaints about it.



More information about the Python-list mailing list