python/flask TypeError: 'float' object is not callable -


i'm deploying simple api written in python (flask), weird error "typeerror: 'float' object not callable". however, object int type, confirmed. tried enforcing int type "for counter in range(int(additional_params_count)):" didn't help.

below error message , source

 1  <type 'int'>  [20130826-16:14pm] [flats_api] [error] exception on /v1/closest_point [get]  traceback (most recent call last):    file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1817, in wsgi_app      response = self.full_dispatch_request()    file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1477, in full_dispatch_request      rv = self.handle_user_exception(e)    file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1381, in handle_user_exception      reraise(exc_type, exc_value, tb)    file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in full_dispatch_request      rv = self.dispatch_request()    file "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1461, in dispatch_request      return self.view_functions[rule.endpoint](**req.view_args)    file "/var/www/flats_api/flats_api.py", line 104, in closest_point      counter in range(0,additional_params_count):  typeerror: 'float' object not callable 

source:

def closest_point():          lng = request.args.get('lng', default=none, type=float)          lat = request.args.get('lat', default=none, type=float)           price_min = request.args.get('price_min',default=none, type=float)          price_max = request.args.get('price_max',default=none, type=float)           rooms_min = request.args.get('rooms_min',default=none, type=float)          rooms_max = request.args.get('rooms_max',default=none, type=float)           if (lng != none) , (lat != none):                  range = 0.1                  lng_min = lng - range                  lng_max = lng + range                  lat_min = lat - range                  lat_max = lat + range                   cur = g.db.cursor()                  query = "select id, link, price, longitude, latitude " + database_table_name + " latitude >= " + str(lat_min) + " , latitude <= " + str(lat_max) + " , longitude >= " + str(lng_min) + " , longitude <= " + str(lng_max)                   # have 5 basic parameters group by. count number of additional parameters know how many add                  additional_params_count = 0                  if price_min:                          query = query + " , price >= " + str(price_min)                          additional_params_count = additional_params_count + 1                  query = query + "group 1,2,3,4,5"                  print additional_params_count                  print type(additional_params_count)                  counter in range(0,additional_params_count):                          print counter                          query = query + "," + str(counter + 6)                  query = query + ";"                  print query                  cur.execute(query)                  columns = [desc[0] desc in cur.description]                  rows = cur.fetchall()                  flats_json = []                  row in rows:                          flats_json.append(dict((k,str(v)) k,v in zip(columns,row)))                  response_body = str(rows)                  return json.dumps(flats_json)          else:                  return "one of lng or lat parameters missing" 

you assigned range float in code, don't otherwise can't access range() built-in then:

if (lng != none) , (lat != none):      range = 0.1       ########### 

demo:

>>> range = 0.1 >>> range() traceback (most recent call last):   file "<ipython-input-39-7b0c968826c1>", line 1, in <module>     range() typeerror: 'float' object not callable 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -