problem of types:

Laurent l.exsteens at gmail.com
Sat Jan 14 03:13:48 EST 2006


I do not understand why he is talking me about 'str', no str given!!!

I have this:

---------------------------------------------

def to_float(elt):
  if type(elt) is list:
    return map(to_float, elt)
  else:
    return float(elt)

def Denombrement(A,b,c,type):
  .
  .
  .
  A = to_float(A)
  b = to_float(b)
  c = to_float(c)
  .
  .
  .

if __name__ == '__main__':
  A = [[1,0],[0,1]]
  b = [2,2]
  c = [1,1]
  type = 'min'

  Denombrement(A, b, c, type)

-------------------------------------------

And this error msg:
-------------------------
Traceback (most recent call last):
  File "./Denombrement.py", line 160, in ?
    Denombrement(A, b, c, type)
  File "./Denombrement.py", line 31, in Denombrement
    A = to_float(A)
  File "./Denombrement.py", line 10, in to_float
    if type(elt) is list:
TypeError: 'str' object is not callable

------------------------------------------

Changing 'list' to 'type(list)' don't change anything!!!!




More information about the Python-list mailing list