Rectangle 27 1

Python EXscript AttributeError: 'str' object has no attribute 'connect'?


if Connection_Type == '1':
    conn = Telnet()
elif Connection_Type == '2':
    conn = SSH2()
'SSH2()'.connect
'Telnet()'.connect
if Connection_Type == '1':
    conn = 'Telnet()' 
elif Connection_Type == '2':
    conn = 'SSH2()'

If you have imported SSH or Telnet from somewhere and presuming they are classes then remove the single quotes and you will create an instance which should work once the classes have a connect method.

Thanks guys. Made perfect sense once it was pointed out to me.

yes, conn is string type variable and string variable do not have connect method.

Note