Good practices for Python

Good practices for Python
Photo by Claudio Rolli / Unsplash

Path management :

Why You Should Start Using Pathlib As An Alternative To the OS Module
First reason: object-oriented programming
Should You Use Python pathlib or os?
A duel between two Python path libraries


Python f-strings

Numpy

loadtxt
where
find_nearest

đź’ˇ
zefrfez

Matplotlib

plot only 1 figure:

fig_1 = plt.figure("Figure 1")
plt.title('')
plt.xlabel('Longueur')
plt.ylabel('Pertes')
plt.grid(True, color = "grey", linestyle = "--")

plt.plot(x, y, label= '')
plt.legend()
Matplotlib 1 figure

Subplots:

plt. becomes ax. for ax.legend & ax.plot
ax.set_title/xlabel/ylabel

fig, ax = plt.subplots(nrows=2, ncols=1)
ax est une liste d'axes => unpack it
fig, (ax1, ax2) = plt.subplots(nrows=2, ncols=1)

Dynamic subplots:
https://stackoverflow.com/questions/12319796/dynamically-add-create-subplots-in-matplotlib

Differences between axes, figure, plt:

https://stackoverflow.com/questions/37970424/what-is-the-difference-between-drawing-plots-using-plot-axes-or-figure-in-matpl