BitBake makes it easy to use Python code in variable expansion with the following syntax:
VARIABLE = "${@<python-command>}"
This gives huge flexibility to the user, as can be seen in the following example:
DATE = "${@time.strftime('%Y%m%d',time.gmtime())}"
This results in the DATE variable containing today's date.