[Python] how to return value from a different script in python

Discussão em 'Python' iniciado por Stack, Fevereiro 23, 2025.

  1. Stack

    Stack Membro Participativo

    I am trying to access the file name that is gathered from one of my python scripts in and use it in a different script, I will show my code below. Currently I tried returning the filename value, however I believe I am getting whats called the object or memory value instead of the file name. Any help or tips to getting this figured out?

    The function with the value I want

    def selected_file(event, listbox, menu):
    item = listbox.curselection()
    if item:
    filename = listbox.get(item[0])
    popup_menu(event, menu, listbox)
    print(f"{filename} selected")
    return filename


    The function I want to retrieve the value with

    def folders_setup(self):
    filename = functions.selected_file
    print(f"for {filename}")
    labelsFrame = Frame(self.folders_frame)
    labelsFrame.pack(side=TOP, pady=8, fill=X)
    Label(labelsFrame, text="Folders")


    What shows when I run my code

    for <function selected_file at 0x10880f9c0>
    craftpix-net-622999-free-pixel-art-tiny-hero-sprites selected



    Anything helps thanks!

    Btw the "craftpix-net-622999-free-pixel-art-tiny-hero-sprites selected" is what I want the "0x10880f9c0" to print.

    Continue reading...

Compartilhe esta Página