I have (anonymized) a hash constructed from values in Python 2.6.8:
sys.stderr.write('#' + str(dictionary['Field 4']) + '#\n')
kpis_found.append(float(int(dictionary['Field 1']), 1) *
max(float(dictionary['Field 2']), 1) *
max(float(dictionary['Field 3']), 1) *
max(float(dictionary['Field 4']), 1) *
max(float(dictionary['Field 5']), 1))
The output I get is:
[Fri Jul 13 09:04:44 2012] [error] [client ::1] #3#
[Fri Jul 13 09:04:44 2012] [error] [client ::1] Traceback (most recent call last):
[Fri Jul 13 09:04:44 2012] [error] [client ::1] File "/Users/jonathan/mirror/civic/google_maps/index.cgi", line 357, in <module>
[Fri Jul 13 09:04:44 2012] [error] [client ::1] max(float(dictionary['Field 4']), 1) *
[Fri Jul 13 09:04:44 2012] [error] [client ::1] TypeError: float() takes at most 1 argument (2 given)
To the best of my knowledge, the CSV files yield (usually) strings convertible to ints, or (occasionally) strings convertible to floats. If I run into a NULL, that should be easier to diagnose. The debugging output appears to confirm that the field in question is ‘3’.
How is this getting a TypeError? I’ve run through parentheses to ensure that I’m not calculating
max(float(foo, bar))
but instead calculating
max(float(foo), bar)
Any insight would be welcome.
Pretty sure that’s your problem. You end up with
float(<int_value>, 1).This was tested with Python 3.1.2, but…