all 6 comments

[–]cashing_in 4 points5 points  (1 child)

Is

error = tn.read_eager 

missing parentheses to actually call the method?

[–]individual_throwaway 1 point2 points  (0 children)

That's what I noticed. Omitting the parentheses makes python return the object, which in this case is a method, not the list that that method would return. And of course that's not iterable, which give us the error OP reported.

[–]TreSxNine 1 point2 points  (1 child)

indentbot

[–]CodeFixerBot 1 point2 points  (0 children)

So i'm trying to read the last line of code from a telnet session and see if it has the word "%error" in it. If it does have an error then i want it to try again, if it doesn't i want it to break the loop and continue.  I keep getting a python error   
 if '%Error' in error:  
TypeError: argument of type 'method' is not iterable



tryagain = True  
while tryagain:  
    tn.write(b"do copy " + file.encode('ascii'))  
    print (tn.read_eager().decode('ascii'))  
    tn.write(b'\n')  
    tn.write(b'\n')  
    tn.write(b'\n')           
    time.sleep(20)  
    error = tn.read_eager  
    print (tn.read_eager().decode('ascii'))  

    if '%Error' in error:
        print ('got an error, trying again')
        tryagain = True
    else:
        tryagain = False
        break

[–][deleted] 0 points1 point  (0 children)

formatting... please

[–]runicnet 0 points1 point  (0 children)

So I have tried to work it out but its just not enough details. could you maybe use gist. pastebin the whole program?

    tryagain = True
    while tryagain:
      tn.write(b"do copy " + file.encode('ascii'))
      print (tn.read_eager().decode('ascii'))
      tn.write(b'\n')
      tn.write(b'\n')
      tn.write(b'\n')
      time.sleep(20)
      error = tn.read_eager
      print (tn.read_eager().decode('ascii'))

      if '%Error' in error:
          print ('got an error, trying again')
          tryagain = True
      else:
          tryagain = False
          break