Accueil > Programmation > python > Classes Python
Classes Python
Publié le 26 octobre 2017, dernière mise-à-jour le 12 mars 2025, > 12 visites, >> visites totales.
Une classe est un objet qui a déjà des valeurs, des propriétés. Une classe est un programme qui sait déjà faire des choses évoluées et spécifiques.
On écrit import scipy,re
pour importe les classes scipy et re. On peut alors utiliser l’objet fftpack contenu dans scipy en écrivant scipy.fftpack
On écrit from scipy import fftpack
pour importer l’objet scipy.fftpack. On peut alors utiliser l’objet fftpack contenu dans scipy en écrivant fftpack
différentes classes utiles :
classe wave :
https://docs.python.org/2/library/w...
classe re :
https://docs.python.org/2/library/r...
classe scipy # apt-get install python3-scipy
https://docs.scipy.org/doc/scipy/re...
from scipy import fftpack
https://docs.scipy.org/doc/scipy/re...
classe matplotlib apt-get install python-matplotlib python3-matplotlib
http://matplotlib.org/api/pyplot_ap...
import matplotlib.pyplot as plt
classe pylexique https://pylexique.readthedocs.io/fr...
python3 -m venv /tmp/ytdlp-poub&& source /tmp/ytdlp-poub/bin/activate && pip install pylexique
print(pylexique.Lexique383().lexique["manger"][1].phon) = "m@Ze"
https://sekoudiaonlp.github.io/pylexique/fr_FR/readme.html
"ortho": "manger", "phon": "m@Ze", "lemme": "manger", "cgram": "NOM", "genre": "m", "nombre": "s", "freqlemfilms2": 5.62, "freqlemlivres": 4.05, "freqfilms2": 5.62, "freqlivres": 4.05, "infover": "", "nbhomogr": 2, "nbhomoph": 7, "islem": True, "nblettres": 6, "nbphons": 4, "cvcv": "CVCCVC", "p_cvcv": "CVCV", "voisorth": 9, "voisphon": 12, "puorth": 6, "puphon": 4, "syll": "m@-Ze", "nbsyll": 2, "cv_cv": "CV-CV", "orthrenv": "regnam", "phonrenv": "eZ@m", "orthosyll": "man-ger", "cgramortho": "NOM,VER", "deflem": "100", "defobs": "33", "old20": 1.35, "pld20": 1.25, "morphoder": "manger", "nbmorph": "1"
créer sa classe perso :
CFR.py :
class CFichiersRepertoires(object):
g=9.81#Ici Une Variable Commune A Tous Les CFichiersRepertoires()
def __init__(self,vit=0.0):
self.vitesse=vit
self.vitesse=10.5#Ici Une Variable Différente pour chaque élément
importer sa classe perso depuis un dossier :
dossier="PROGRAMMATION/PYTHON/DOC/CLASSES"
if dossier not in sys.path:
sys.path.append(dossier)
import CFR
from CFR import CFichiersRepertoires
les classes prédéfinies : https://www.python-course.eu/python3_magic_methods.php
Binary Operators
Operator Method
+ object.__add__(self, other)
- object.__sub__(self, other)
* object.__mul__(self, other)
// object.__floordiv__(self, other)
/ object.__truediv__(self, other)
% object.__mod__(self, other)
** object.__pow__(self, other[, modulo])
<< object.__lshift__(self, other)
>> object.__rshift__(self, other)
& object.__and__(self, other)
^ object.__xor__(self, other)
| object.__or__(self, other)
Extended Assignments
Operator Method
+= object.__iadd__(self, other)
-= object.__isub__(self, other)
*= object.__imul__(self, other)
/= object.__idiv__(self, other)
//= object.__ifloordiv__(self, other)
%= object.__imod__(self, other)
**= object.__ipow__(self, other[, modulo])
<<= object.__ilshift__(self, other)
>>= object.__irshift__(self, other)
&= object.__iand__(self, other)
^= object.__ixor__(self, other)
|= object.__ior__(self, other)
Unary Operators
Operator Method
- object.__neg__(self)
+ object.__pos__(self)
abs() object.__abs__(self)
~ object.__invert__(self)
complex() object.__complex__(self)
int() object.__int__(self)
long() object.__long__(self)
float() object.__float__(self)
oct() object.__oct__(self)
hex() object.__hex__(self
Comparison Operators
Operator Method
< object.__lt__(self, other)
<= object.__le__(self, other)
== object.__eq__(self, other)
!= object.__ne__(self, other)
>= object.__ge__(self, other)
> object.__gt__(self, other)