Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ---
- ## π Docstring
- ΠΠ΄Π½Π° ΠΈΠ· Π²Π°ΠΆΠ½ΡΡ Π²Π΅ΡΠ΅ΠΉ Π² Π»ΡΠ±ΠΎΠΌ ΠΊΠΎΠ΄Π΅ β **ΡΠΈΡΠ°Π±Π΅Π»ΡΠ½ΠΎΡΡΡ**.
- ΠΠ΄Π½Π°ΠΊΠΎ Π½Π΅ Π²ΡΠ΅Π³Π΄Π° ΠΏΠΎΠ»ΡΡΠ°Π΅ΡΡΡ ΠΎΠΏΡΠΈΠΌΠΈΠ·ΠΈΡΠΎΠ²Π°ΡΡ Π°Π»Π³ΠΎΡΠΈΡΠΌΡ ΠΈΠ»ΠΈ Π½Π°Π·Π²Π°Π½ΠΈΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ , ΡΡΠ½ΠΊΡΠΈΠΉ,
- ΠΌΠ΅ΡΠΎΠ΄ΠΎΠ² ΠΈΠ»ΠΈ ΠΊΠ»Π°ΡΡΠΎΠ² Π΄Π»Ρ ΠΏΠΎΠ»Π½ΠΎΠ³ΠΎ ΠΏΠΎΠ½ΠΈΠΌΠ°Π½ΠΈΡ ΠΊΠΎΠ΄Π°. ΠΠ»Ρ ΡΡΠΎΠ³ΠΎ Π½Π°ΠΌ Π½ΡΠΆΠ½Ρ docstring. <br>
- Docstring ΠΏΠΈΡΠ΅ΡΡΡ ΡΠΎΠ»ΡΠΊΠΎ Π΄Π»Ρ ΠΎΠ±ΡΠ΅ΠΌΠ½ΡΡ ΠΈ ΡΠ»ΠΎΠΆΠ½ΡΡ Π·Π°Π΄Π°Ρ
- (Π½Π°Π»ΠΈΡΠΈΠ΅ ΠΌΠ½ΠΎΠΆΠ΅ΡΡΠ²Π° ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ , Π΄Π»ΠΈΠ½Π½ΠΎΠΉ ΡΠ΅ΠΏΠΎΡΠΊΠΈ ΠΏΠΎΡΡΡΠΎΠ΅Π½ΠΈΡ Π»ΠΎΠ³ΠΈΠΊΠΈ ΠΈ Ρ.Π΄.). <br><br>
- <b>ΠΠ±Π½ΠΎΠ²Π»Π΅Π½ΠΈΠ΅ 04.04.2024:</b> docstring ΠΏΠΈΡΡΡΡΡ ΠΏΠΎ ΠΏΡΠ°Π²ΠΈΠ»Π°ΠΌ google. https://sphinxcontrib-napoleon.readthedocs.io/en/latest/example_google.html <br><br>
- Π ΡΠ°ΠΌΠΈΡ docstring ΠΎΠΏΠΈΡΡΠ²Π°ΡΡΡΡ ΠΊΠ°ΠΊ ΠΌΠΈΠ½ΠΈΠΌΡΠΌ 4 Π²Π΅ΡΠΈ:
- 1. ΠΎΡΠ½ΠΎΠ²Π½Π°Ρ ΠΈΠ΄Π΅Ρ ΡΡΠ½ΠΊΡΠΈΠΈ, ΠΌΠ΅ΡΠΎΠ΄Π° ΠΈΠ»ΠΈ ΠΊΠ»Π°ΡΡΠ°;
- 2. ΡΠΎΠ΄ ΠΈΡΠΏΠΎΠ»ΡΠ·ΡΠ΅ΠΌΡΡ ΠΏΠ΅ΡΠ΅ΠΌΠ΅Π½Π½ΡΡ (ΠΠΏΡΠΈΠΎΠ½Π°Π»ΡΠ½ΠΎ, Π΅ΡΠ»ΠΈ Π½Π΅ ΡΠΊΠ°Π·Π°Π½Π° Π°Π½Π½ΠΎΡΠ°ΡΠΈΡ);
- 3. ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΡ (ΠΡΠ»ΠΈ Π΄ΠΎΠ±Π°Π²Π»Π΅Π½ΠΎ Π±ΠΎΠ»ΡΡΠ΅ ΡΠ΅ΠΌ ΠΎΠ΄Π½ΠΎ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΠΈΠ»ΠΈ ΠΈΡΠΊΠ»ΡΡΠ΅Π½ΠΈΠ΅ ΡΠ²Π»ΡΠ΅ΡΡΡ ΠΊΠ°ΡΡΠΎΠΌΠ½ΠΎΠ΅);
- 4. ΠΎΠΆΠΈΠ΄Π°Π΅ΠΌΡΠΉ ΡΠ΅Π·ΡΠ»ΡΡΠ°Ρ, ΡΠΎ Π΅ΡΡΡ ΡΠΎ, ΡΡΠΎ ΠΌΡ ΠΏΠΎΠ»ΡΡΠ°Π΅ΠΌ Π½Π° Π²ΡΡ ΠΎΠ΄Π΅ (ΡΡΠΎΠΉ ΡΠ°ΡΡΡΡ ΠΌΠΎΠΆΠ½ΠΎ ΠΏΡΠ΅Π½Π΅Π±ΡΠ΅Π³Π°ΡΡ,
- Π΅ΡΠ»ΠΈ ΡΠΊΠ°Π·Π°Π½ ΠΎΠΆΠΈΠ΄Π°Π΅ΠΌΡΠΉ ΡΠΈΠΏ ΠΎΡΠ²Π΅ΡΠ° ΠΏΠΎΡΠ»Π΅ Π°ΡΠ³ΡΠΌΠ΅Π½ΡΠΎΠ²; Π½Π°ΠΏΡΠΈΠΌΠ΅Ρ, def sum(a, b) -> int) <br><br>
- Π ΠΎΡΠ½ΠΎΠ²Π½ΠΎΠΌ docstring ΠΏΠΈΡΡΡΡΡ Π½Π° Π°Π½Π³Π»ΠΈΠΉΡΠΊΠΎΠΌ. ΠΠ°ΠΏΡΠΈΠΌΠ΅Ρ:
- <pre>
- <code>
- def module_level_function(param1, param2=None, *args, **kwargs):
- """This is an example of a module level function.
- The format for a parameter is::
- name (type): description
- The description may span multiple lines. Following
- lines should be indented. The "(type)" is optional.
- Multiple paragraphs are supported in parameter
- descriptions.
- Args:
- param1 (int): The first parameter.
- param2 (:obj:`str`, optional): The second parameter. Defaults to None.
- Second line of description should be indented.
- *args: Variable length argument list.
- **kwargs: Arbitrary keyword arguments.
- Returns:
- bool: True if successful, False otherwise.
- The return type is optional and may be specified at the beginning of
- the ``Returns`` section followed by a colon.
- The ``Returns`` section may span multiple lines and paragraphs.
- Following lines should be indented to match the first line.
- The ``Returns`` section supports any reStructuredText formatting,
- including literal blocks::
- {
- 'param1': param1,
- 'param2': param2
- }
- Raises:
- AttributeError: The ``Raises`` section is a list of all exceptions
- that are relevant to the interface.
- ValueError: If `param2` is equal to `param1`.
- """
- if param1 == param2:
- raise ValueError('param1 may not be equal to param2')
- return True
- </code>
- </pre>
- **_N.B._**: Π½Π΅ Π·Π°Π±ΡΠ²Π°Π΅ΠΌ ΠΏΡΠΎ Π°Π½Π½ΠΎΡΠ°ΡΠΈΡ, Π² ΠΎΡΠΎΠ±Π΅Π½Π½ΠΎΡΡΠΈ ΠΊΠΎΠ³Π΄Π° ΠΎΠΏΡΠ΅Π΄Π΅Π»ΡΠ΅ΡΡΡ ΠΊΠ»Π°ΡΡ ΠΈΠ»ΠΈ ΠΊΠΎΠΌΠΏΠ»Π΅ΠΊΡΠ½Π°Ρ ΡΡΠ½ΠΊΡΠΈΡ !
- ---
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement