views:

117

answers:

3

I'm learning Python and ran into some code that has this line...

self.clear()

I am curious as to what it would do and why would someone need to do this?

+5  A: 

That line calls the clear method on the current object. What the clear method actually does depends on what class this code is inside.

Mark Byers
+1  A: 

If you found it inside the function, that looked like:

def __parse(self,filename):

then you will probably find something similar to this:

def clear(self):

If you find it, there's the code, that will be executed within self.clear()

eumiro
A: 

sorry if it wasnt clear but i just found the code for clear() ... all it did was clear the UserDict object before assigning new values to it....i misunderstood the code and thought the writer was actually deleting the current object....anyway answer found....thanks for the help guys....i will be more careful in the future about how i word my questions and especially about what not to ask in the first place.

kd