0

Return from another file

I have two files. File1: string = “string" def returnString(): return string File 2: import file1 string = file1.returnString() I get an exception : AttributeError I think it's a beginners mistake, but I don't know, what I'm doing wrong here. Thanks in advance for your help.

4th Jan 2021, 5:25 PM
Fu Foy
Fu Foy - avatar
2 Answers
+ 2
Is file1 the name of your script? Did you try def returnString(): return "My string" in file 1?
4th Jan 2021, 5:32 PM
Lisa
Lisa - avatar
+ 1
I renamed some files and did not notice, that I import file1 from file2 and the other way around... đŸ€ Thanks for your help!
4th Jan 2021, 5:39 PM
Fu Foy
Fu Foy - avatar