What are Generators?

Generators are special functions that implement or generate iterators. Generators are functions which behave like iterators, but can have better performance characteristics. These include: Creating values on demand, resulting in lower memory consumption. The values returned are lazily generated. Hence, it is not necessary to wait until all the values in a list are generated before using them. However, the set of generated values can only be used once....

April 21, 2017 · 1 min · Rezha Julio

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

Function in Python are First-Class Object

Python’s functions are first-class objects. You can assign them to variables, store them in data structures, pass them as arguments to other functions, and even return them as values from other functions. Grokking these concepts intuitively will make understanding advanced features in Python like lambdas and decorators (I will cover two this in the next post) much easier. It also puts you on a path towards functional programming techniques. In this post I’ll guide you through a number of examples to help you develop this intuitive understanding....

April 6, 2017 · 8 min · Rezha Julio

Django 1.11 Release Note a Reading

Django 1.11 is released for the world to use. It comes with a lot of changes, which can take some time to read. In this video, GoDjango read all of the release notes so you can just put on some headphones and hit play. ...

April 5, 2017 · 1 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