问题
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