On Tue, Feb 2, 2010 at 8:04 AM, Zheng Jiekai <zjkh...@gmail.com> wrote: > I'm beginning my python learning. My python version is 3.1 > > I‘v never learnt OOP before. > So I'm confused by the HTMLParser > > Here's the code: >>>> from html.parser import HTMLParser >>>> class parser(HTMLParser): > def handle_data(self, data): > print(data) > >>>> p = parser() >>>> page = """<html><h1>Title</h1><p>I'm a paragraph!</p></html>""" >>>> p.feed(page) > Title > I'm a paragraph! > > > I'm wondering if I can pass the data generated by ' handle_data' to a > function instead of just print the data.
Sure. In fact print() is a function. Just replace print(data) with my_function(data). Kent _______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor