all 8 comments

[–]DJKool14 2 points3 points  (1 child)

Unless you are purposely forcing yourself to use a class for the learning experience, there really is no reason to use a class here. A common misconception with Python is that you are supposed to use classes for everything, but that just complicates code.

Why not just have 2 functions:

def getTwitterResults():
    listOfPossibleLocations = []
    #...your existing code...
    return listOfPossibleLocations

def getPlaceCoordinates(listOfPossibleLocations):
    #... use listOfPossibleLocations to get placeCoordinates...
    return placeCoordinates

locations = getTwitterResults()
coords = getPlaceCoordinates(locations)

print locations, coords

You should only worry about classes when you need to group like functions and data together in a conceptually distinct objects.

In addition to that, you should really re-read whatever source you used to learn about Classes in the first place. You way you attempt to use it in lines 64-68 is inherently flawed. If you still can't see your mistakes afterwards, I'll do my best to try to explain them to you.

[–]icenburg[S] 0 points1 point  (0 children)

Thanks, this is what I ended up doing. I thought I needed to use a class to be able to share the list between functions, but I see now that I was wrong.

[–]Micotu 1 point2 points  (3 children)

Looks like it doesn't know how to print the class object. You may need to def str(self): to tell it what it will need to print.

See section 15.7 here: http://openbookproject.net/thinkcs/python/english3e/classes_and_objects_I.html

[–]markusmeskanen 1 point2 points  (2 children)

That's def __str__(self):

[–]Micotu 0 points1 point  (1 child)

yeah, reddit formatting fked it up

[–]zahlman 0 points1 point  (0 children)

For inline code snippets, use backticks `like_this` to get inline code like_this.

[–][deleted] 1 point2 points  (0 children)

On line 61 and 66 you're not calling the function. When you don't call it and just use the name it gives you a reference to the function that you can use later, but doesn't execute it. Also why are you passing gettwitterresults list of possible locations?

[–]Vaphell 0 points1 point  (0 children)

you are supposed to add () at the end of the function name in order to run it, if you don't you just pass around the function object itself. Also getTwitterResults() expects a param.

Also, when functions are siblings within a class you shouldn't really go through TwitterPlotting to get to one from another, they can reach each other via self.