diff options
author | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 23:22:42 -0500 |
---|---|---|
committer | Leonard Richardson <leonard.richardson@canonical.com> | 2011-02-26 23:22:42 -0500 |
commit | 1330639ff7ae099ce80e77a8b6be6a0d75b60f04 (patch) | |
tree | 88ce4c276bd87885a54a099692bb469e4c27965c | |
parent | 5082ca97607846f3be18859f1b803ac15ef77083 (diff) |
Minor cleanup and adding docstrings.
-rw-r--r-- | beautifulsoup/element.py | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/beautifulsoup/element.py b/beautifulsoup/element.py index 519a9da..d37124f 100644 --- a/beautifulsoup/element.py +++ b/beautifulsoup/element.py @@ -562,7 +562,7 @@ class Tag(PageElement): def __repr__(self, encoding=DEFAULT_OUTPUT_ENCODING): """Renders this tag as a string.""" - return self.decode(eventual_encoding=encoding) + return self.encode(encoding) def __unicode__(self): return self.decode() @@ -578,9 +578,15 @@ class Tag(PageElement): def decode(self, indent_level=None, eventual_encoding=DEFAULT_OUTPUT_ENCODING, substitute_html_entities=False): - """Returns a string or Unicode representation of this tag and - its contents. To get Unicode, pass None for encoding.""" + """Returns a Unicode representation of this tag and its contents. + :param eventual_encoding: The tag is destined to be + encoded into this encoding. This method is _not_ + responsible for performing that encoding. This information + is passed in so that it can be substituted in if the + document contains a <META> tag that mentions the document's + encoding. + """ attrs = [] if self.attrs: for key, val in self.attrs: @@ -655,7 +661,7 @@ class Tag(PageElement): substitute_html_entities=False): """Renders the contents of this tag as a Unicode string. - :param eventual_encoding: The document is destined to be + :param eventual_encoding: The tag is destined to be encoded into this encoding. This method is _not_ responsible for performing that encoding. This information is passed in so that it can be substituted in if the |