Jinja2 also defines the ~ operator, which automatically converts arguments to string first, as an alternative to the + operator.
Example:
{% set p = year ~ "https://stackoverflow.com/" ~ month ~ "https://stackoverflow.com/" ~ day ~ "https://stackoverflow.com/" ~ post.slug %}
See Other operators or, if you really want to use str, modify the Environment.globals dictionary.