Python function telling me I sent two arguments when I only sent one
google-app-engine, python
Solution
The first argument is set implicitly by python when the method is bound to an instance. In this case util. When defining a method in a class, the first argument is usually named `self` and is the bound object.
class Utilities():
def create_table(self, results):
pass # more to come
Should work fine :)
Edit: This also means, you can call such methods also when not bound to an instance (i.e. obj.fun()):
utils = Utilities()
Utilities.create_tables(utils, results)
Problem
I'm using Google's webapp framework. What I'm trying to do below is simply send the results of query.fetch to a function that will take the results and create a table with them. ``` class Utilities(): def create_table(results): #Create a table for the results.... ``` variable `results` gets two results back from query.fetch ``` results = query.fetch(10) #This returns two results util = Utilities() util.create_table(results) ``` Then I get the error util.create_table(results) TypeError: create_table() takes exactly 1 argument (2 given) I had thought that `results` would automatically get passed by reference. Am I wrong?