Modifications

Sauter à la navigation Sauter à la recherche
338 octets ajoutés ,  10 novembre 2016 à 21:42
Ligne 3 : Ligne 3 :  
{{traduction}}
 
{{traduction}}
 
== Importer un fichier de code ==
 
== Importer un fichier de code ==
Just like with regular Python you can import and use code from files in your own MicroPython scripts. This is great for breaking a large or complex script into smaller pieces, or for sharing and reusing code with multiple projects.
+
Comme pour une version standard de Python, vous pouvez importer et exécuter du code provenant de fichiers python dans votre script MicroPython. Cette approche est idéal pour décomposer un long script ou script complexe en des morceaux de codes plus petits. Cela permet de réutiliser ou partager du code entre plusieurs project. Cela facilite également le processus de maintenance.
   −
If you aren't familiar with Python's module support be sure to [https://docs.python.org/3/tutorial/modules.html read the official documentation first]. Python allows you to put code in a .py file and import it from other scripts in the same directory. You can even get more advanced and create packages which include multiple .py files and expose them in different ways. Most third-party Python libraries are available as packages which you install and import in your own scripts.
+
Si vous n'avez pas l'habitude des modules Python alors vous devriez prendre connaissance [https://docs.python.org/3/tutorial/modules.html de la documentation officielle] (''Python.org, Anglais''). Python vous permet de placer du codans dans un fichier .py puis de l'importer depuis un autre script se trouvant dans le même répertoire. Vous pouvez même opter pour une approche plus avancée en créant un paquet (''package'' en anglais) contenant plusieurs fichiers .py que vous pourrez exposer de différentes façons. La plupart des bibliothèques Python tierces sont disponibles sous forme de paquet que vous pouvez installer et importer dans vos propres scripts.
    
We'll start by looking at how to import code from a single '''.py''' file in your MicroPython script.  First make sure you have a board running MicroPython and are familiar with copying files to and from the board.
 
We'll start by looking at how to import code from a single '''.py''' file in your MicroPython script.  First make sure you have a board running MicroPython and are familiar with copying files to and from the board.
29 922

modifications

Menu de navigation