Transfer from one variable

104 Views Asked by At
def main():
with Path(filepath).open("rb") as fp:
    image_binary = fp.read()
    response = requests.post(
        PINATA_BASE_URL + endpoint,
        files={"file": (filename, image_binary)},
        headers=headers,
    )
    ipfs_hash = response.json()["IpfsHash"]
    print(response.json())
    image_uri = "{}{}".format(first_part_image_uri, ipfs_hash)
    print(image_uri)

    # Aufruf Funktion create_image_uri_meta_file
    simple_collectible = SimpleCollectible[len(SimpleCollectible) - 1]
    token_id = simple_collectible.tokenCounter()
    create_image_uri_meta_file(response, token_id)
return image_uri

I want to transfer the variable image_uri into another Python script. The best attempt so far I have succeeded with:

from scripts.upload_to_pinata import main
image_uri = main()
image_uri_from_upload = image_uri

However, the problem arises here that I take over all commands and other variables from main. I would like to take over however ONLY the one variable. Does anyone have a solution, idea or suggestion how I can transfer only the one variable between the Python scripts? Here is a part of the script in which the variable should be inserted.

from scripts.upload_to_pinata import main

image_uri = main()
image_uri_from_upload = image_uri

image_uri_from_upload = ""

def main():

Thanks in advance for the support.

0

There are 0 best solutions below