[Tutor] how to pass data to aother function from a class?

Zheng Jiekai zjkhere at gmail.com
Tue Feb 2 14:04:22 CET 2010


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.

Sorry for my poor English
and Thank you for tutoring!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20100202/5ed95638/attachment.htm>


More information about the Tutor mailing list