Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between @param and: param in Pycharm

I want to document a class, and I have seen that in PyCharm when a docstring is added automatically it adds

:param param_name1: 
:param param_name2:

However, I have seen that some people use

@param param_name1:
@param param_name2:

I wonder which of both is valid, and which one is the one that a Pythonista should house.

I also wonder if I should include the @type or :type for describing the data type of a parameter.

"""
:type rating: int
:param rating: hotel rating
"""

This is the way I am writing my docstring. So, is it okay or is there a much better way or stand way to do it?

like image 384
lmiguelvargasf Avatar asked Sep 16 '25 09:09

lmiguelvargasf


1 Answers

As explained in https://www.jetbrains.com/pycharm/help/using-docstrings-to-specify-types.html#d331661e129

:param param_name1: 
:param param_name2:

is reStructuredText format instead of

@param param_name1:
@param param_name2:

is Epitext format

Epitext format can be enabled with File > Settings > Python Integrated Tools and set "Docstring format" to "Epytext"

like image 78
Loïc G. Avatar answered Sep 17 '25 22:09

Loïc G.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!