OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

String literal with triple quotes in function definitions (what is a docstring?)

  • Thread starter Thread starter Estarius
  • Start date Start date
E

Estarius

Guest
I am following the Python tutorial and at some point they talk about how the 1st statement of a function can be a String Literal. As far as the example goes, this String Literal seems to be done with three "s, giving in the example

Code:
"""Print a Fibonacci series up to n."""

According to this documentation, this would be used mainly to create some kind of automatically produced documentation.

So I am wondering if someone here could explain to me what are these string literals exactly?
<p>I am following the Python tutorial and at some point they talk about how the 1st statement of a function can be a String Literal. As far as the example goes, this String Literal seems to be done with three <code>"</code>s, giving in the <a href="http://docs.python.org/release/2.7.3/tutorial/controlflow.html#defining-functions" rel="noreferrer">example</a></p>

<pre><code>"""Print a Fibonacci series up to n."""
</code></pre>

<p>According to this documentation, this would be used mainly to create some kind of automatically produced documentation.</p>

<p>So I am wondering if someone here could explain to me what are these string literals exactly?</p>
 

Latest posts

Top