TypeError: 'list' object is not callable

Asked by Andrew Valancius

So I wrote this:

def find_orefolders(): # Finds all ore folders
 ScanFolder = Region( ) # Sets area to search for folders
 ScanFolder.findAll( )
 orefolders = list(ScanFolder.getLastMatches())
#gets locations of all folders and orders them by y position
 sorted_orefolders = sorted(orefolders, key=by_y)
 return sorted_orefolders
 #print (sorted_orefolders)
 #print (len(sorted_orefolders))

def find_rocks(): # Finds all individual asteroids on screen
 SelectRock = Region( )
 try:
  SelectRock.findAll( )
  foundRocks = list(SelectRock.getLastMatches())
  sorted_foundRocks = sorted(foundRocks, key=by_y)
  return sorted_foundRocks
 except: FindFailed
 return 0

def folder_opener(): # This function opens the needed amount of folders
 try:
  rockCount = len(find_rocks())
 except: TypeError
 rockCount = 0
 while rockCount < 6:
  orefolders = find_orefolders()
  for m in orefolders(): # <-------- this is line 93 <-------------------------------------
   # Finds the region in which to check the arrow orientation
   foundFolder = Region(m)
   arrow = foundFolder.nearby(1)
   arrow = arrow.left(19)
   #arrow.highlight(5)
   if arrow.exists( ,1): # If the arrow is closed it opens it and restarts the while loop
    click(m)
    orefolders = find_orefolders()
    break
   rockCount = len(find_rocks())
   if rockCount >= 6:
    break

folder_opener() # <------this is line 107

When i run it i get this error message:

[error] Stopped
[error] An error occurs at line 107
[error] Error message: Traceback (most recent call last):
File "C:\Users\Andrew\AppData\Local\Temp\sikuli-tmp8647247163812478721.py", line 107, in
folder_opener()
File "C:\Users\Andrew\AppData\Local\Temp\sikuli-tmp8647247163812478721.py", line 93, in folder_opener
for m in orefolders():
TypeError: 'list' object is not callable

I'm rather new with python and programming in general and i don't know how to get rid of this issue. I'm assuming it's something to do with the fact i'm getting the value from a function, since i wrote something almost identical to perform the same task, just without putting the code in functions. But the thing is supposed to check to see if an arrow by the folder is in a open or closed position.

Question information

Language:
English Edit question
Status:
Solved
For:
SikuliX Edit question
Assignee:
No assignee Edit question
Solved by:
RaiMan
Solved:
Last query:
Last reply:
Revision history for this message
Andrew Valancius (valancal) said :
#1

oh and idk if it shows but all the indenting is correct, and if it appears different it's just from the copying and pasting

Revision history for this message
Best RaiMan (raimund-hocke) said :
#2

for m in orefolders():

orefolders is a variable.

orefolders() forces Python to see it as method/function, which it is not.

use:
for m in orefolders:

Revision history for this message
Andrew Valancius (valancal) said :
#3

Thank you so much. I hope you get something out of all this help you provide because between questions i've asked and other peoples questions you've helped me with dozens of problems :D

Revision history for this message
Andrew Valancius (valancal) said :
#4

Thanks RaiMan, that solved my question.