October 6th, 2004, 03:48 AM
This is the first program I have started to write, and am getting hung up on a few things..
All I'm trying to do is have the system alert the system bell a few times once a connection is made to my computer by a certain IP and port number, and then sound the bell only once or twice once the connection goes away. Then it will have to loop back to the beginning to watch for a connection to be made, and go away and so on till I kill it. I am only at the very first part of this so far.
connected = "no"
while connected != "yes":
for l in o:
connected = "yes"
print "Index Exception"
Now the problem is this. It will only find a match if there is a established connection before I start the program. So lets say there is no current ftp connection, and I start the program it seems to be running however once I do make a connection It never will sound the bell..
So It seems to be only going though the for loop once.
Thanks for any help.
October 6th, 2004, 04:31 AM
You need to put your code like this:
for l in o....
BTW it is usually a good idea to avoid single letter variable names like o and l as they look very much like 0O and 1|.
October 6th, 2004, 08:15 AM
You should also use the boolean values True or False; you're currently using two strings (yes and no) i.e.
Note: The boolean values True and False can also be expressed as 1 and 0 respectivly. If you're running a version older than Python 2.3 then you will need to use these rather numbers. It might also be handy to know that an empty object (string, list, tuple or dictionary) are also treated as being False.
connected = False
while not connected:
Last edited by netytan; October 6th, 2004 at 08:20 AM.
October 11th, 2004, 01:59 AM
Thanks for the help.
After putting this...
After the while statement got it looping the way I wanted it to. Now I just need to figure out the rest of it out.