How to fix the error :'range' object is not callable in python3.6 [closed]

蹲街弑〆低调 提交于 2020-01-06 06:23:43

问题


my code looks like:

list_var = ['rh','temp','tl','Tt','DPD','PAR']
for L in range(1, len(list_var)):
     for subset in itertools.combinations(list_var, L):
          f = 'inf ~ {} + C(area)'.format(' * '.join(list(subset)))

error 'range' object is not callable jumped up even I changed len(list_var) into a number. Can you identify the problem and fix it? Thank you in advance!!!


回答1:


I can reproduce the issue when assigning the range name to a range instanciated object:

>>> range = range(10)
>>> range(1)
Traceback (most recent call last):
  File "<string>", line 301, in runcode
  File "<interactive input>", line 1, in <module>
TypeError: 'range' object is not callable

you probably reassigned the name earlier in your code, triggering this exact error.

A quick & dirty fix is:

del range


来源:https://stackoverflow.com/questions/48522852/how-to-fix-the-error-range-object-is-not-callable-in-python3-6

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!