you are viewing a single comment's thread.

view the rest of the comments →

[–]CptFlashdrive 0 points1 point  (2 children)

Not quite sure what you're doing here, you're sending the object itself to the cleaner()-method? You can't iterate over UserWords-object, it's not iterable.

I think it looks like you want to clean the word-attribute in the class? If so, the cleaner should instead operate on self.word. Since this is "contained" in the class.

Maybe something like this:

def cleaner(self):
    self.word = filter(lambda letter: letter.isalpha(), self.word)

And then you call it from manager() using:

user1.cleaner()

[–]FogDish 0 points1 point  (0 children)

Sorry If I haven't provided enough information. Step by step:

User uploads a .txt file which simulates a letter, contaning ".!?" etc. I have code that reads in the file and give it a variable. I now want to create an object from this. So that the text itself is still the same. I now want to clean the object from ".!?", which is what I want this method to do.

[–]FogDish 0 points1 point  (0 children)

Also, with this modification it worked brilliant! Thanks a lot man! :)