pour la creation de package j'ai compris, la pas de probleme parcontre c'est pour son exploitation qu'il y a probleme


package\fonctions.py

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
""" module multipli contenant la fonct table et un test table4 """
 
import os
def table(nb,max=10):
    i=0
    while i<max:
          print(i+1,"*",nb,"=",(i+1)*nb)
          i += 1
# test fonction table
if __name__ == "__main__":
   table(4)
   os.system("pause")


pourquoi cela ne marche pas (comme indiqué dans le bookin)
test_package_import.py

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
""" test table 5 - package """
 
import os
import package.fonctions
fonctions.table(5)
os.system("pause")
et ce lui la marche test_package_import.py

""" test table 5 - package """
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
 
import os
import package.fonctions
package.fonctions.table(5)
os.system("pause")

la seule differance import package.fonctions.table(5) et fonctions.table(5)
Merci de repondre.