type float problem

rolandschulz rolandschulzhd at googlemail.com
Thu Mar 26 20:27:12 EDT 2009


On Mar 26, 2:41 pm, Pavol Juhas <pavol.ju... at gmail.com> wrote:
> This has nothing to do with numpy, the issue is the string "%"
> operator
> cannot convert list to a float (Line 3 in your example gives a list).
> In '"%f" % x' the x has to be a number or tuple.
>
> Does not work:
>     print "%f" % [1.0]

Yes that helps. Why is it that the %-operator requires a tuple and
does not work with a list?

Thus why doesn't this work: "%d %d"%[2,2]
but instead it has to be: "%d %d"%tuple([2,2])
or: "%d %d"%(2,2)

Thanks
Roland



More information about the Python-list mailing list