On Feb 29, 12:55 am, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote: > On Thu, 28 Feb 2008 10:39:51 -0000, Steven D'Aprano > <[EMAIL PROTECTED]> declaimed the following in > comp.lang.python: > > > By that logic, we should see this: > > > >>> len("a string") > > '8' > > 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. > > And rightly rejected by many other programming languages, including > > modern Python, not to mention calculators, real mathematics and common > > sense. > > 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. -- http://mail.python.org/mailman/listinfo/python-list