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

what is the use of " .format(**config)) "

asked 2017-09-05 10:54:11 -0500

MukulKhanna gravatar image

updated 2017-09-05 11:00:12 -0500

jayess gravatar image

in this link ^, they have this piece of code (shown below)

rospy.loginfo("Config set to {int_param}, {double_param}, {str_param}, {bool_param}, {size}".**format(**config))**

what is the use of the bold part in the above code snippet ^

I am trying to dynamically reconfigure values of upper and lower HSV range values, so do I need to use this .format thing at the end of


if not, then what is its use?

edit retag flag offensive close merge delete


I formatted the code in your question. To format your code please use the 101010 button not".

jayess gravatar image jayess  ( 2017-09-05 11:00:49 -0500 )edit

Do you literally mean


or do you mean



jayess gravatar image jayess  ( 2017-09-05 11:04:20 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2017-09-05 11:13:55 -0500

jayess gravatar image

updated 2017-09-05 17:40:48 -0500

I'm assuming that you mean

rospy.loginfo("Config set to {int_param}, {double_param}, {str_param}, {bool_param}, {size}".format(**config))

This is just plain Python. From the Python docs

str.format(*args, **kwargs)

Perform a string formatting operation. The string on which this method is called can contain literal text or replacement fields delimited by braces {}. Each replacement field contains either the numeric index of a positional argument, or the name of a keyword argument. Returns a copy of the string where each replacement field is replaced with the string value of the corresponding argument.

As for the **config, checkout this answer on StackOverlfow:

This is a shortcut that allows you to pass multiple arguments to a function directly using either a list/tuple or a dictionary.

As for using it with numpy, I'm not too familiar with numpy but I don't believe that you do. But, you should ask a new question about that specifically.

edit flag offensive delete link more


I believe that I originally quoted the wrong part of the correct docs so I updated my answer to the correct part.

jayess gravatar image jayess  ( 2017-09-05 17:39:56 -0500 )edit

Question Tools



Asked: 2017-09-05 10:54:11 -0500

Seen: 362 times

Last updated: Sep 05 '17