jagomart
digital resources
picture1_Python Projects Pdf 188827 | Dsl 4 Python Projects


 126x       Filetype PDF       File size 0.33 MB       Source: dbdmg.polito.it


File: Python Projects Pdf 188827 | Dsl 4 Python Projects
data science lab structuring python projects databaseand data mining group andrea pasini elena baralis structuring python projects the code of a python project is organized in packages and modules package ...

icon picture PDF Filetype PDF | Posted on 03 Feb 2023 | 2 years ago
Partial capture of text on file.
                     Data Science Lab
                           Structuring Python projects
     DataBaseand Data Mining Group                        Andrea Pasini, Elena Baralis
           Structuring Python projects
      ▪ The code of a Python project is organized in 
         packages and modules
      ▪ Package:
          ▪ Represented with a directory in the file system
          ▪ Collects a set of Python modules
          ▪ A folder must contain a __init__.py file to be 
             considered a Python package
      ▪ Module
          ▪ Represented with a Python file (.py)
          ▪ Contain attributes, functions and class definitions
                                                                   2
            Structuring Python projects
       ▪ Example: project structure
                MyProject                      Project main folder
                       algorithms               Package
                            __init__.py         Init file
                            utils.py            Modules
                            classifier.py
                       graphics
                            __init__.py
                            charts.py
                      main_script.py      Main script: run with command
                                          python main_script.py
                                                                          3
         Structuring Python projects
     ▪ Example: content of Python module
            graphics       charts.py
               __init__.py  import matplotlib.pyplot as plt
               charts.py    import os
                            def plot_result():
               Function       ...
               definition     plt.plot(...)
                              ...
                            plot_path = "../Data/plots"
                Attribute   if not os.path.exists(plot_path):
              Initialization  os.makedirs(plot_path)
              operations
                                                       4
The words contained in this file might help you see if this file matches what you are looking for:

...Data science lab structuring python projects databaseand mining group andrea pasini elena baralis the code of a project is organized in packages and modules package represented with directory file system collects set folder must contain init py to be considered module attributes functions class definitions example structure myproject main algorithms utils classifier graphics charts script run command content import matplotlib pyplot as plt os def plot result function definition path plots attribute if not exists initialization makedirs operations...

no reviews yet
Please Login to review.