def getText(nodelist):
"""Extracts the text between XML tags
I took this directly from http://docs.python.org/library/xml.dom.minidom.html.
For example, if I have a tag <Tag>525</Tag> this method returns me '525'
"""
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
Gives me IndentationError: unindent does not match any outer indentation level
def getText(nodelist):
rc = ""
for node in nodelist:
if node.nodeType == node.TEXT_NODE:
rc = rc + node.data
return rc
Does not. All I am doing is deleting the docstring comment. What is going on?
Go to the setting of your code editor and enable the option which shows the tab and whitespaces. Once this feature in turned on, you will see small single dots in between your code, where each dot represents whitespace or a tab.
Handling Docstring IndentationAny indentation in the first line of the docstring (i.e., up to the first newline) is insignificant and removed. Relative indentation of later lines in the docstring is retained. Blank lines should be removed from the beginning and end of the docstring.
The indentation error can occur when the spaces or tabs are not placed properly. There will not be an issue if the interpreter does not find any issues with the spaces or tabs. If there is an error due to indentation, it will come in between the execution and can be a show stopper.
This error occurs when Python is looking for an indented block of code after certain types of statements. The indented block tells Python that the code within the block is relevant to the statement.
Your docstring starts with tabs. Make your code only use spaces for indentation (or only tabs), including the indentation for the docstrings.
Make sure you are not mixing spaces and tabs for your indentation
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With