MCPcopy Index your code
hub / github.com/csev/py4e / string

Method string

code3/bs4/element.py:853–867  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

clearMethod · 0.95
appendMethod · 0.45

Tested by

no test coverage detected