Python function correctly/incorrectly?
Posted
by
Anthony Kernan
on Stack Overflow
See other posts from Stack Overflow
or by Anthony Kernan
Published on 2012-03-19T01:58:37Z
Indexed on
2012/03/19
2:03 UTC
Read the original article
Hit count: 249
I'm just starting too use python, learning experience. I know the basics logic of programming. I have a function in python that is running everytime, even when it's not supposed to. I use an if statement in the beginning of the function. I don't know why this if statement is not working, confused. I have another function that is similar and works correctly. Am I missing something simple?
Here's the function that is not working...
def check_artist_art():
if os.path.exists("/tmp/artistinfo") and open("/tmp/artistinfo").read() != title:
#if artist == "":
if os.path.exists(home + "/.artist"):
os.remove(home + "/.artist")
if os.path.exists("/tmp/artistinfo"):
os.remove("/tmp/artistinfo")
print artist
return False
else:
os.path.exists("/tmp/artistinfo") and open("/tmp/artistinfo").read() == artist
return False
return True
And this is the similar function that is working correctly..
def check_album():
if os.path.exists("/tmp/albuminfo") and open("/tmp/albuminfo").read() != album:
if os.path.exists(home + "/.album"):
os.remove(home + "/.album")
if os.path.exists("/tmp/albuminfo"):
os.remove("/tmp/albuminfo")
return False
elif os.path.exists("/tmp/trackinfo") and open("/tmp/trackinfo").read() == artist + album:
return False
return True
Any help is greatly appreciated.
© Stack Overflow or respective owner