0

I study how to document my code. So, I prepared a file docstrings.py and placed it in a directory. Now I would like to have a look at what I documented. In other words I want to type help(docstrings.square) and get the documentation on square function in my module.

>>> import sys
>>> sys.path.append("C:\Users\Michael\PycharmProjects\Docstrings")

Result:

SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 2-4: truncated \UXXXXXXXX escape

What's wrong?

1 Answer 1

1

Backslashes have to be doubled in string literals:

>>> sys.path.append("C:\\Users\\Michael\\PycharmProjects\\Docstrings")

Unless you use a raw string:

>>> sys.path.append(r"C:\Users\Michael\PycharmProjects\Docstrings")
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. It's working. Another question. How can I use PyDoc. I read that PyDoc explores all catalogues from sys.path and finds the selected module. But how to edit sys.path for PyDoc?
Try modifying the PYTHONPATH environment variable. PyDoc should honor it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.