ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

'type' object is not subscriptable

asked 2012-07-23 07:02:07 -0500

punching gravatar image

updated 2014-01-28 17:13:07 -0500

ngrennan gravatar image

I have a node that is a service that lists wifi access points and their details. When I first run rosrun there's no errors. Then I make a service request and it says Error processing request: 'type' object is not subscriptable. I'm sure it's a basic Python error but I can't figure out what it is. Thanks!

The relevant code:

    ssid_list.append(ssid)
    strength_list.append(strength)
    secured_list.append(secured)

  return WifiListResponse[String(ssid_list), UInt8(strength_list), Bool(secured_list)]

my .srv file:

int8 request
---
string[] ssid_list
uint8[] strength_list
bool[] secured_list
edit retag flag offensive close merge delete

Comments

1

Unfortunately, I think the code you pasted is not enough to infer what's going wrong. Please paste the complete relevant code not just snippets that don't contain any context. Also, please copy-paste the complete backtrace.

Lorenz gravatar image Lorenz  ( 2012-07-23 07:41:16 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted
2

answered 2012-07-23 08:09:01 -0500

Eric Perko gravatar image

Your code is not valid Python.

Try something like

WifiListResponse(ssid_list, strength_list, secured_list)
edit flag offensive delete link more
0

answered 2012-07-23 10:07:33 -0500

punching gravatar image

I tried that but I had somehow put in [ instead of (.

Eric, what you posted worked. Thanks. Sometimes you can't see the trees through the forest!

edit flag offensive delete link more

Comments

1

Please use the comment function instead of posting a new answer. Also, if your question is solved, make sure to mark the correct answer as "Accepted" using the checkmark undernearth the voting buttons.

Eric Perko gravatar image Eric Perko  ( 2012-07-23 10:24:17 -0500 )edit

Question Tools

Stats

Asked: 2012-07-23 07:02:07 -0500

Seen: 4,798 times

Last updated: Jul 23 '12