Feb-08-2017, 04:41 AM
I don't know if this has been asked before but, I am using the ftp library and making a tiny client. In my connect function i save the username and password to a variable. Now i understand that i can't use those variables outside so what i did was declare 2 more variables called perm_Uname and perm_pass. These are declared outside. I set the perm variables to equal the other and when i run them they stay the same. My code will make more sense.
I need the password and username saved for other functions.
help is really appreciated.
from ftplib import FTP import getpass ftp = FTP() def connect(): try: ftp.connect("ipaddress", 21) except: print("Some error occured check to see if the ip is correct.") return False username = input("Username: ") password = getpass.getpass("Password: ") perm_Uname = username perm_pass = password try: ftp.login(username, password) print("Login Passed") except: print("Login failed") del username del password perm_pass = "" perm_Uname = "" connect() print(perm_pass) print(perm_Uname)The output is what i declared them as. Why?
I need the password and username saved for other functions.
help is really appreciated.