Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Convert py file to exe
#11
(Jul-17-2020, 08:30 PM)SmukasPlays Wrote: When I execute any of the functions that are in the other files, they open but the CMD also open
It's not so common for .py files to execute outside the main Python file.
In a package or module usage it's most common that other files are imported an not run before called in main Python file.
I guess if want to execute those files on it's own,then need to make .exe of each them with --noconsole .
Then call the .exe and not .py file

To give a example what i talking about.
# life.py
def foo():
    return 42

if __name__ == '__main__':
    print(foo())
# meaning.py
import life

def bar():
    print(f'The meaning of life is {life.foo()}')

bar()
Run:
Output:
C:\code\a_folder λ python meaning.py The meaning of life is 42
life.py is not doing any executing on it's own but get get called in meaning.py.
So it increases functionality of the main file.
If change to this.
# life.py
def foo():
    return 42

print(foo())
Run:
Output:
C:\code\a_folderλ python meaning.py 42 the meaning of life is 42
No get life.py get executed on import,this rarely a wanted behavior.
Reply


Messages In This Thread
Convert py file to exe - by SmukasPlays - Jul-16-2020, 05:11 PM
RE: Convert py file to exe - by buran - Jul-16-2020, 06:28 PM
RE: Convert py file to exe - by SmukasPlays - Jul-17-2020, 03:43 PM
RE: Convert py file to exe - by palladium - Jul-17-2020, 02:32 AM
RE: Convert py file to exe - by snippsat - Jul-17-2020, 04:07 PM
RE: Convert py file to exe - by SmukasPlays - Jul-17-2020, 08:30 PM
RE: Convert py file to exe - by Axel_Erfurt - Jul-17-2020, 04:24 PM
RE: Convert py file to exe - by buran - Jul-17-2020, 04:51 PM
RE: Convert py file to exe - by snippsat - Jul-17-2020, 04:57 PM
RE: Convert py file to exe - by buran - Jul-17-2020, 05:02 PM
RE: Convert py file to exe - by snippsat - Jul-18-2020, 12:22 AM
RE: Convert py file to exe - by SmukasPlays - Jul-18-2020, 03:15 AM
RE: Convert py file to exe - by princetonits - Jul-20-2020, 07:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question [SOLVED] Correct way to convert file from cp-1252 to utf-8? Winfried 8 1,176 Feb-29-2024, 12:30 AM
Last Post: Winfried
  Convert File to Data URL michaelnicol 3 1,273 Jul-08-2023, 11:35 AM
Last Post: DeaD_EyE
  Python Script to convert Json to CSV file chvsnarayana 8 2,622 Apr-26-2023, 10:31 PM
Last Post: DeaD_EyE
  Convert Excel file into csv with Pipe symbol.. mg24 4 1,389 Oct-18-2022, 02:59 PM
Last Post: Larz60+
  Need Help: Convert .pcl file to .pdf file ManuRaval 6 2,610 Sep-13-2022, 01:31 PM
Last Post: ManuRaval
  Convert legacy print file to XLSX file davidm 1 1,840 Oct-17-2021, 05:08 AM
Last Post: davidm
  Yahoo_fin, Pandas: how to convert data table structure in csv file detlefschmitt 14 7,927 Feb-15-2021, 12:58 PM
Last Post: detlefschmitt
  [split] How to convert the CSV text file into a txt file Pinto94 5 3,439 Dec-23-2020, 08:04 AM
Last Post: ndc85430
  CPC File Format (Cartesian Perceptual Compression) - Can Python Convert / Handle Them PSKrieger 2 2,522 Nov-11-2020, 02:57 PM
Last Post: PSKrieger
  Convert file of hex strings to binary file medatib531 4 13,899 Oct-09-2020, 05:42 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020