Python can't divide??!?!
John Hunter
jdhunter at ace.bsd.uchicago.edu
Sat Feb 7 00:19:28 EST 2004
>>>>> "Kurt" == Kurt B Kaiser <kbk at shore.net> writes:
This prints a float
>>> print (3.0 / 5)
0.6
This prints a tuple of floats
>>> print (3.0 / 5, 3.0 / 5)
(0.59999999999999998, 0.59999999999999998)
This prints a (length 1) tuple of floats
>>> print (3.0 / 5, )
(0.59999999999999998,)
The thing that may be tripping you up is that (val) is simply the
value, and (val,) is a tuple containing the value as the first
element. As for printing a value versus a tuple of values, that's the
__repr__ versus __str__ distinction previous posters have referred to.
JDH
More information about the Python-list
mailing list