Modifications

Sauter à la navigation Sauter à la recherche
Ligne 105 : Ligne 105 :  
Notez que l'instruction d'importation référence le fichier '''add.py''' en utilisant un "''nom d'importation absolu''". Par exemple, le fonction add est importée depuis '''test.add'''.  Le 'test.' est le nom du paquet/package, par exemple: le nom du répertoire du paquet/package. Le 'add' derrière le 'test.add' est le nom du fichier python (add.py) où l'interpréteur Python trouvera la fonction à importer.  
 
Notez que l'instruction d'importation référence le fichier '''add.py''' en utilisant un "''nom d'importation absolu''". Par exemple, le fonction add est importée depuis '''test.add'''.  Le 'test.' est le nom du paquet/package, par exemple: le nom du répertoire du paquet/package. Le 'add' derrière le 'test.add' est le nom du fichier python (add.py) où l'interpréteur Python trouvera la fonction à importer.  
   −
Suivant l'instruction {{fname|1=from <font color="teal">test</font>.<font color="purple">add</font> import <font color="Chocolate">add</font> }}, nous importons donc une fonction '''add''' depuis le fichier ''add.py'' se trouvant dans le ''répertoire "test"'' (le "''test.add''").  
+
Suivant l'instruction '''{{fname|1=from <font color="teal">test</font>.<font color="dark purple">add</font> import <font color="Orange Red">add</font> }}''', nous importons donc une fonction '''add''' depuis le fichier ''add.py'' se trouvant dans le ''répertoire "test"'' (le "''test.add''").  
    
Vous  You can't run a command like "'''from add import add'''" in the __init__.py since Python would get confused if it should load an add.py from inside the module or from elsewhere.  Using the full name '''test.add''' tells Python to use the '''add.py''' module inside the '''test''' package directory.
 
Vous  You can't run a command like "'''from add import add'''" in the __init__.py since Python would get confused if it should load an add.py from inside the module or from elsewhere.  Using the full name '''test.add''' tells Python to use the '''add.py''' module inside the '''test''' package directory.
29 917

modifications

Menu de navigation