Lambda Functions in Python

The lambda keyword in Python provides a shortcut for declaring small anonymous functions. Lambda functions behave just like regular functions declared with the def keyword. They can be used whenever function objects are required. For example, this is how you’d define a simple lambda function carrying out an addition: >>> add = lambda x, y: x + y >>> add(5, 3) 8 You could declare the same add function with the def keyword:...

April 16, 2017 · 5 min · Rezha Julio

One Hell Named JSON

Today on my AWS Lambda Python function, its suffering from an error ValueError: Expecting property name: line 1 column 2 (char 1). This function receive a json events from AWS Kinesis and send it back to kafka. Apperently this is an error from json.loads if you have a json strings with a single quote >>> json_string = "{'name': rezha, 'ganteng': true}" >>> json.loads(json_string) # ValueError: Expecting property name: line 1 column 2 (char 1) To fix this, you could use ast....

April 3, 2017 · 1 min · Rezha Julio