Re: Multiplying sequences with floats

2006-03-29 Thread Caleb Hattingh
Hi Dennis Sure, I get it. I do most of my work in Delphi, which is, shall we say, not lax about floating-point types. Thinking about this more, I realise my initial interest was in looking at the // operator as something new, whereas I now see it probably just wraps math.floor(); obviously then

Re: Multiplying sequences with floats

2006-03-28 Thread Caleb Hattingh
Christoph I understand the explanation regarding the underlying math.floor() call. Were I using this functionality in my code, int(a//b)* some_list would not be something I consider a big deal. However, I see what you're saying: The multiplcation by list can only work with an int, and you hav

Re: Multiplying sequences with floats

2006-03-28 Thread Caleb Hattingh
Hi Fredrik Fair enough; I wasn't precise. Upon further reflection, I actually meant floor division, via the // operator. In the following snippet: >>> 4/2 2 >>> 4//2 2 >>> 4.0/2.0 2.0 >>> 4.0//2 2.0 >>> 4.0//2.0 2.0 We know the last two operations can only return what are effectively integer n

Re: Multiplying sequences with floats

2006-03-25 Thread Christoph Zwerschke
Caleb Hattingh wrote: > 4.0//2 doesn't return an integer, but the equality against an integer > still holds. I agree that integer division should return an integer, > because using the operator at all means you expect one. There are actually two conflicting expectations here: You're right, the

Re: Multiplying sequences with floats

2006-03-24 Thread Fredrik Lundh
Caleb Hattingh wrote: > I agree that integer division should return an integer, because > using the operator at all means you expect one. so what is x / y ? an integer division ? something else ? -- http://mail.python.org/mailman/listinfo/python-list

Re: Multiplying sequences with floats

2006-03-24 Thread Caleb Hattingh
Hi Christoph On my linux py-2.4.1: >>> 4.0//2 # Integer division, but still returns a float. 2.0 >>> 4.0//2 == 2 True >>> 4.0//2 doesn't return an integer, but the equality against an integer still holds. I agree that integer division should return an integer, because using the operator at all

Re: Multiplying sequences with floats

2006-03-24 Thread Christoph Zwerschke
Andrew Koenig wrote: > Christoph Zwerschke wrote: > >> Anyway this would be an argument only against the variant of typecasting a >> float with a fractional part. But what about the other variant which >> raises an error if there is a fractional part, but works if the float is >> actually an ex

Re: Multiplying sequences with floats

2006-03-24 Thread Andrew Koenig
"Christoph Zwerschke" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > Anyway this would be an argument only against the variant of typecasting a > float with a fractional part. But what about the other variant which > raises an error if there is a fractional part, but works if the

Re: Multiplying sequences with floats

2006-03-23 Thread Christoph Zwerschke
Dan Sommers wrote: > Christoph Zwerschke wrote: >> I was wondering whether this should be allowed, i.e. multiplication of >> a sequence with a float. There could be either an implicit typecast to >> int (i.e. rounding) ... > > Explicit is better than implicit. I already knew using the word "impli

Re: Multiplying sequences with floats

2006-03-23 Thread Dan Sommers
On Fri, 24 Mar 2006 00:35:44 +0100, Christoph Zwerschke <[EMAIL PROTECTED]> wrote: > Currently, if you write 3*'*', you will get '***', but if you write > 3.0*'*', you will get an error (can't multiply sequence by non-int). > I was wondering whether this should be allowed, i.e. multiplication of