Retourner au contenu associé (entrée de forum : fonctions)
Posté par kernelox le 14 juin 2015 à 14:08. En réponse au message fonctions. Évalué à 1.
j'ai trouvé un code de ce type sur internet à ce propos :
def func(): print("func() in one.py")
print("top-level in one.py")
if name == "main": print("one.py is being run directly") else: print("one.py is being imported into another module")
quand on invoque python one.py , pourquoi on a une execution de ce type : top-level in one.py one.py is being run directly
Pourquoi on zappe la fonction "func" et on n'a pas le "print("func() in one.py")" à l'execution . Merci
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# code ./?
Posté par kernelox . En réponse au message fonctions. Évalué à 1.
j'ai trouvé un code de ce type sur internet à ce propos :
file one.py
def func():
print("func() in one.py")
print("top-level in one.py")
if name == "main":
print("one.py is being run directly")
else:
print("one.py is being imported into another module")
quand on invoque python one.py , pourquoi on a une execution de ce type :
top-level in one.py
one.py is being run directly
Pourquoi on zappe la fonction "func" et on n'a pas le "print("func() in one.py")" à l'execution .
Merci