Avatar of GVNPublic123
GVNPublic123
 asked on

Python TypeError

Ok, so these lines usually work fine, but sometime produce type error (the bold part is producing it).
 1228         url = "http://www.google.com/" % params
 1229        [b] output = getPage("https://api-ssl.bitly.com/v3/shorten?login=xxx&apiKey=xxx&%s&format=txt"\
 1230         % urllib.urlencode({'longUrl':url}))[:22].replace("http://", "")[/b]

Open in new window


Error:
TypeError: unsubscriptable object
      args = ('unsubscriptable object',)

Also in debug report, when this error occured both params and url variables were setup fine. HELP!
Python

Avatar of undefined
Last Comment
pepr

8/22/2022 - Mon
pepr

You should copy/paste our error message with the trace.
GVNPublic123

ASKER
But I gave you traced line of code and error...what more do you need? There aint no more in report.
pepr

How do you run it?  Is it a part of some web server code?  Where the 'args = ...' came from?
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy
GVNPublic123

ASKER
No idea...its just a random python fail.
GVNPublic123

ASKER
It occured, but I cant recreate it. I put exception handling for next time.
pepr

How do you run your Python code?  Is it saved in a file and launched say from command line?  How do you know that the mentioned line caused the error?  What version of Python do you use?  What OS do you use?
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
GVNPublic123

ASKER
CentOS 5, its a website, python 2.4.3

Got it from bug report.
ASKER CERTIFIED SOLUTION
pepr

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
GVNPublic123

ASKER
Yeh, I put exception handling in so now I dont care if slicing fails. The worker will pick it up later automatically if it fails on request.
pepr

Sorry I could not be more explicit.  Thanks for the points, and have a good time ;)
I started with Experts Exchange in 2004 and it's been a mainstay of my professional computing life since. It helped me launch a career as a programmer / Oracle data analyst
William Peck