Convenience property to get the single string within this tag. :Return: If this tag has a single string child, return value is that string. If this tag has no children, or more than one child, return value is None. If this tag has one child tag, return value is th
(self)
| 851 | |
| 852 | @property |
| 853 | def string(self): |
| 854 | """Convenience property to get the single string within this tag. |
| 855 | |
| 856 | :Return: If this tag has a single string child, return value |
| 857 | is that string. If this tag has no children, or more than one |
| 858 | child, return value is None. If this tag has one child tag, |
| 859 | return value is the 'string' attribute of the child tag, |
| 860 | recursively. |
| 861 | """ |
| 862 | if len(self.contents) != 1: |
| 863 | return None |
| 864 | child = self.contents[0] |
| 865 | if isinstance(child, NavigableString): |
| 866 | return child |
| 867 | return child.string |
| 868 | |
| 869 | @string.setter |
| 870 | def string(self, string): |