[Python] Choose location of compiled file

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    So I have a program that generates the bytecode of a python file. In this case i want to import statements from the bytecode(.pyc) file. I believe the file has to be in a parent folder so lets just say I want the file once compiled to be stored at /root/users/folder. But the code here only allows me just to compile it and store it into the current folder.

    Code:


    from py_compile import compile as bytecode

    bytecode(file='file.py')


    Now I know a could just just move the file using another function but is their another way to store it specifically like how modules are stored in /root/users/__pycache__ when it is imported.

    Continue reading...

Compartilhe esta Página