0

Code:

def edit_properties(self, device, ssc_command="hexa", value="test")
    result = self.edit_devices.edit_device_property(device, ssc_command=value)

I want to pass "ssc_command" as a key to self.edit_devices.edit_device_property(device, ssc_command=value) and value as a value.

sai
  • 13
  • 1
  • 5
  • Can you give an example of how `edit_properties` might be called, and what you would expect from that call? – Scott Hunter Aug 02 '18 at 15:34
  • Possible duplicate of [Most pythonic way of assigning keyword arguments using a variable as keyword?](https://stackoverflow.com/questions/6976658/most-pythonic-way-of-assigning-keyword-arguments-using-a-variable-as-keyword) – Thierry Lathuille Aug 02 '18 at 15:41
  • @ScottHunter I got it ...It's not possible to pass as i asked. – sai Aug 02 '18 at 15:42

1 Answers1

2

Dictionary/kwargs expansion. First, you make a dict with ssc_command as the key and value as the value, and then you use ** to expand it into a set of keyword arguments:

result = self.edit_device.edit_device_property(device, **{ssc_command:value})
Green Cloak Guy
  • 23,793
  • 4
  • 33
  • 53