开发者

What does this code do in Python?

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?


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


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()


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜