Skip to content

Commit 8eb2c99

Browse files
authored
Create I Best Practices.py
1 parent f2fea6a commit 8eb2c99

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
"""**************************************************************************************************************************************************************
2+
goal of this course is to transform you into a Python expert, and so the first chapter starts off with best practices when writing functions.
3+
You'll cover docstrings and why they matter and how to know when you need to turn a chunk of code into a function. You will also learn the details of how Python passes
4+
5+
Docstrings
6+
==========
7+
- makes your code easier to use, read, maintain
8+
9+
@ anatomy of docstring
10+
-----------------------
11+
def func_name(arguments):
12+
'''
13+
Description of what it does
14+
Description of argument(s) if any
15+
Description of return value(s) if any
16+
Description of errors raised if any
17+
Optional extra notes or examples
18+
'''
19+
@ docstring Formats
20+
-----------------------
21+
- Google style (pupular) - NumpyDoc (popular) - reStructuredText - EpyText
22+
23+
----Google style === straight to the point eg. '''Stack the columns''' and just Arg:, Raises: , Returns: , Notes:
24+
----NumpyDoc === more vertical with line tittles, takes more space
25+
26+
@ Review Documentation
27+
-----------------------
28+
>>>>>>>> func_name.__doc__ ====review documentation
29+
>>>>>>>> .getdoc(dunc_name) (inspect module)
30+
31+
++
32+
import inspect
33+
print(inspect.getdoc(func_name))
34+
**************************************************************************************************************************************************************"""

0 commit comments

Comments
 (0)