Reputation: 21
I've got a problem with a function which is defined in a Python class:
class DatabaseHandler:
def get_messages_by_last_mid(self, uidReceiver, last_mid):
self.cursor.execute("SELECT uidSender, content FROM messages WHERE MID > ?", str(last_mid))
ret_value = []
result = self.cursor.fetchone()
while result != None:
ret_value.append(result)
result = self.cursor.fetchone()
return ret_value
def get_messages_by_last_group_id(self, uidReceiver, last_gid):
self.cursor.execute("SELECT gidreceiver, uidsender, content FROM groupmessages WHERE mid > ?", str(last_gid))
ret_value = []
result = self.cursor.fetchone()
while result != None:
ret_value.append(result)
result = self.cursor.fetchone()
return ret_value
But only the function get_messages_by_last_mid() works, the other one produces the following error:
AttributeError: DatabaseHandler instance has no attribute 'get_messages_by_last_group_id'
Thanks in advance :)
Upvotes: 1
Views: 3393
Reputation: 21
Sorry guys, I had used an old package. My problem has been fixed. Thanks for your answers.
Upvotes: 1
Reputation: 4650
Indentation can be a silent killer in Python if you're coming from various other programming languages. As you already know, indentation is how Python determines the scope of methods, functions, classes, loops, etc. as you write your code. Make sure your indentation is consistent! You can use the command-line option -t or -tt to python to check yourself.
Upvotes: 1