Reputation: 13
I'm trying to control my smart light through a python script, the Lamp takes variables in json format like following:
command = json.dumps({"on":false})
The problem now is, that whenever I want to send my code to the lamp, i get an error Message saying
NameError: name 'false' is not defined
How can i make Python ignore the false and just pass it on to the lamp?
Upvotes: 1
Views: 377
Reputation: 184395
Python spells "false" with a capital "f".
command = json.dumps({"on": False})
Don't worry, when it gets converted to JSON it will have the right case. The whole point of the JSON library is to convert JSON strings to and from native Python objects.
Of course, with something this trivial, you could just write it as a string directly:
command = '{"on": false}'
Upvotes: 3