How about adding rational fraction to Python?
steve at holdenweb.com
Sat Mar 1 06:39:56 CET 2008
Dan Bishop wrote:
> On Feb 29, 12:55 am, Dennis Lee Bieber <wlfr... at ix.netcom.com> wrote:
>> On Thu, 28 Feb 2008 10:39:51 -0000, Steven D'Aprano
>> <st... at REMOVE-THIS-cybersource.com.au> declaimed the following in
>>> By that logic, we should see this:
>>>>>> len("a string")
>> Why? len() is a function that /counts/ the elements of the argument
>> -- said count remains in integral value (I presume we don't have a 1.5
>> character long string)
> The relevant point is that len() is a function that returns a
> DIFFERENT type than its argument, and nobody ever complains about is.
A language that restricted its functions to returning the same types as
its arguments wouldn't be very much use, would it? And what about
functions that have multiple arguments of different types?
>>> And rightly rejected by many other programming languages, including
>>> modern Python, not to mention calculators, real mathematics and common
>> I know of no calculator that has "integers" for normal math -- and
>> the HP50 even emphasizes this by putting a decimal point into "integer"
>> quantities. Heck -- most calculators work in BCD floats. Most merely
>> suppress the decimal point if the trailing digits are all 0s
> My TI-89 treats them differently: 1.0/2.0 is 0.5, while 1/2 is the
> symbolic expression 1/2.
Any you don't even have to import anything from __future__!
Steve Holden +1 571 484 6266 +1 800 494 3119
Holden Web LLC http://www.holdenweb.com/
More information about the Python-list