PEP 238 (revised)

David Bolen db3l at fitlinxx.com
Fri Jul 27 02:11:46 EDT 2001


"Terry Reedy" <tjreedy at home.com> writes:

> "David Bolen" <db3l at fitlinxx.com> wrote in message
> news:upuanumtb.fsf at ctwd0143.fitlinxx.com...
> 
> > Is the polymorphic argument really true here?
> 
> I think so, even though Guido made it look asymetric in the first
> paragraph.  I can easily imagine that I would want a formula like
> (n-1)//k to give the same numerical value regardless of whether n
> enters as 20 or 20.0 -- the same as (n-1)*k does.  Why should one work
> polymorphically and the other not?

I'm not sure I follow - the section is discussing an alternative where
// does the true division, so the new // functionality would be
polymorphic for true division?  The "argument" I'm not sure about is
that leaving / alone still leaves a problem case when trying to use it
(e.g., the existing classic function with /) in some other polymorphic
case.  I'm just not sure what that case is.

If in the above, you meant / rather than //, then either you want an
integer result polymorphically (in which case I'd think int(expr)
would work), or you want a float result polymorphically (in which case
you'd use // for true division instead).  Yes, the existing classic
operator on its own might not give you the integer polymorphic result, but
it's not "hard" to write as specified here.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list