C
Christoph Zwerschke
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 a
sequence with a float. There could be either an implicit typecast to int
(i.e. rounding), or the above error could occur only for floats with a
fractional part. Usage example: You want to convert a percentage value
(to a number of 0 to 4 stars. You could do this with the expression
percentage/20*'*'
However, this fails if percentage is a float. And even this fails:
percentage//20*'*'
So you have to write
int(percentage//20)*'*'
in which case you may as well write
int(percentage/20)*'*'
again. Ok, it's probably not a big deal but it somehow stroke me as odd
that you can't simply write percentage//20*'*'.
-- Christoph
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 a
sequence with a float. There could be either an implicit typecast to int
(i.e. rounding), or the above error could occur only for floats with a
fractional part. Usage example: You want to convert a percentage value
(to a number of 0 to 4 stars. You could do this with the expression
percentage/20*'*'
However, this fails if percentage is a float. And even this fails:
percentage//20*'*'
So you have to write
int(percentage//20)*'*'
in which case you may as well write
int(percentage/20)*'*'
again. Ok, it's probably not a big deal but it somehow stroke me as odd
that you can't simply write percentage//20*'*'.
-- Christoph