Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In Python Docstrings, What Does `:obj:` do?

I keep seeing docstrings that have lines that read like this:

param : :obj: str

I can't find a reference to what :obj: stands for or does. It seems like it would denote a str object, but I also see

param : int

which doesn't seem to jibe.

Thanks.

like image 422
Paka Avatar asked Dec 13 '16 17:12

Paka


2 Answers

This is Sphinx-related syntax to insert a link to the `str object in the standard Python documentation. See also Python Documentation (:obj:`str`) vs (str).

like image 178
user1919235 Avatar answered Oct 23 '22 16:10

user1919235


This is not built-in Python functionality. The author of the code you're looking at is using some external tool to automatically generate documentation. It looks like Sphinx syntax, but I'm not sure.

I assume you're finding these at the docstrings for functions and methods. The are identifying the types of arguments for the automatic documentation generator to correctly document the function/method signature.

like image 3
skrrgwasme Avatar answered Oct 23 '22 18:10

skrrgwasme