Multiplying sequences with floats
cito at online.de
Fri Mar 24 01:51:10 CET 2006
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 "implicit" would provoke that answer...
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 exact integer, like the result of 4.0//2.
BTW, the multiplication of a sequence with an int does an even more
implicit thing: The number is considered to be zero if it is negative.
> At least until some future version of python in which math.sqrt( 4.0 )
> returns an integer. ;-)
In that version, 4.0//2 would also return an integer... But that is not
something I had in mind.
More information about the Python-list