Python - Function with incorrect return

0

The code below is a simplistic example, but that represents exactly the error it is giving in my official code.

    def MontarURL(self):
    URL = "C:\Users\tttt\Desktop\Imagens\2.png"
    return (URL)

    A = MontarURL
    print (A)

The return should be a URL and returns something like this: main.MontarURL at 0x038EB390 function. This is not just a display issue, because I'm going to need this URL in the normal way for another function.

How do I return exactly what should and not just the memory address where the object is?

    
asked by anonymous 22.07.2018 / 01:51

1 answer

0

You are not calling the function correctly, try this:

def MontarURL():
    URL = "C:\Users\tttt\Desktop\Imagens\2.png"
    return (URL)
# Você precisa chamar a função dessa forma, senão vai 
#retornar o endereço de memória bem como você já descobriu
A = MontarURL()
print (A)
    
22.07.2018 / 03:30