LinuxAnswers - the LQ Linux tutorial section.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 06-26-2004, 06:54 PM   #1
Registered: Aug 2003
Posts: 167

Rep: Reputation: 30
Help with Python debug

CODE STARTS BELOW-----------------------------------------------------------------
import sys

HostAddress =range(10000)
HostName =range(10000)
HostThreshold =range(10000)
HostAlarmLevel =range(10000)
HostDataSend =range(10000)

index = 0

while True:
HostAddress[index] = raw_input("Enter IP Address: ")
HostName[index] = raw_input("Enter host name: ")
HostThreshold[index] = raw_input("Enter threshold: ")
HostAlarmLevel[index] = raw_input("Enter alarm level (1-5 5 being most critical): ")
HostDataSend[index] = raw_input("Store data for this host? (yes or no): ")
index += 1
Option1 = raw_input("Quit? (y/n): ")

if Option1 == 'y':

counter = index
index = 0

CCConfigFile = open("connectcheck.cfg", "w")

while index <= counter:
CCConfigFile.write(str(HostAddress[index] + "\n"))
CCConfigFile.write(str(HostName[index] + "\n"))
CCConfigFile.write(str(HostThreshold[index] + "\n"))
CCConfigFile.write(str(HostAlarmLevel[index] + "\n"))
CCConfigFile.write(str(HostDataSend[index] + "\n"))

index += 1


CODE ENDS-----------------------------------------------------------------------------

When I run this script everything works fine. The file is written as intended, yet I still keep getting this error message:

Traceback (most recent call last):
File "", line 29, in ?
CCConfigFile.write(str(HostAddress[index] + "\n"))
TypeError: unsupported operand type(s) for +: 'int' and 'str'

Any reason why I get this warning?
Old 06-26-2004, 09:16 PM   #2
Senior Member
Registered: Feb 2003
Location: N'rn WI -- USA
Distribution: Kubuntu 8.04, ClarkConnect 4
Posts: 1,142

Rep: Reputation: 47
Try """ CCConfigFile.write(str(HostAddress[index]) + "\n") """

Convert the HostAddress[index] with str() before adding the line-break.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Processing Conflict: python-devel conflicts python< 2.3.4-13.1 guarriman Fedora 2 04-23-2009 07:02 PM
installing python library's (Python Numeric) Four Linux - Newbie 1 10-16-2005 02:31 PM
WineX, python-gnome, and python-gtk DrD Fedora 0 08-03-2004 12:11 PM
[debug]what does the following debug information mean icoming Programming 21 06-08-2004 02:13 AM
install python 2.3 ,necssary to remove python 2.2 ngan_yine Linux - Newbie 7 12-28-2003 04:07 PM

All times are GMT -5. The time now is 09:00 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration