help with str()

Tuxtrax See_my at Signature.com.invalid
Sun Apr 18 07:15:41 EDT 2004


Hi all.

I have need of assistance on something that should be very simple, and 
is driving me absolutely batty. This is a code snippet from a short 
program that downloads news headers via nntplib. getinput() is simply a 
function I have defined for using raw_input in a friendly fashion.


message_request = getinput("\nHow many posts should I be interested in? 
[max 10,000]")

    if int(message_request) > int(number_of_messages):
       print "\nRequest exceeds current available message count. 
Adjusting to %s posts" % number_of_messages
       message_request = number_of_messages
    elif int(message_request) > 10000:
       print "\nRequest exceeds program capacity. Assuming max of 10,000 
posts, and continuing ...."
       message_request = "10000"      
    
      
The trouble comes in when I try to convert last_message into a string:

    last_message = str(int(first_available_message) + 
int(message_request)) 

I also tried variations on a theme like:

last_message = int(first_available_message) + int(message_request)
string_result = str(last message)

No dice. In every case, I get the following error:

Traceback (most recent call last):
  File "headhunter.py", line 317, in ?
    response, poster = n.xhdr("from", 
first_available_message+"-"+str(last_message))
TypeError: 'str' object is not callable

I have tried everything I could think of and there is only one 
possibility still left that I can think of. My theory is this: by using 
the int() function, I am typing the numbers in the last_message 
assignment to type integer, and str() is expecting type float, or 
something.

I am stuck. Thanks for any help you all can provide. I appreciate it.

best regards,

Mathew

-- 
ROT 13 this address to mail me:

bar jbeq abg guerr; uvtu qrfreg zna, gura nqq - ng lnubb qbg pbz.



More information about the Python-list mailing list