“variable de soulignement Python” Réponses codées

Nom de la variable de démarrage avec sous-traitant Python

_bar
#No effect, just hint for the user:
#“Hey, this isn’t really meant to be a part of the public interface 
#of this class.
#Best to leave it alone.”
__bar
#protects the variable from getting overridden in subclasses
__bar__
#It’s best to stay away from using names that start and 
#end with double underscores (“dunders”) in your own programs 
#to avoid collisions with future changes to the Python language.
#reserved for magic methods
Real Raccoon

variable de soulignement Python

_var    #- Preferred convention for internal variables and methods
var_    #- Used to avoid naming conflicts with Python keywords
__var   #- Used for name mangling by Python when used in class context
        #- Python interpreter changes the name of the variable to avoid 
#collision with child class
__var__ #- Reserved for special use in the language
        #- Used as a temporary or don't care varaibles
patrick204nqh

Réponses similaires à “variable de soulignement Python”

Questions similaires à “variable de soulignement Python”

Plus de réponses similaires à “variable de soulignement Python” dans Python

Parcourir les réponses de code populaires par langue

Parcourir d'autres langages de code