Using variables in an expression I am checking for a specific block in a specific theme region. 

{% if page.header_first.blockmachinename %}
   // Show stuff
{% endif %}


This works when I have the right machine name. But I want to be able to use a variable in place of blockmachinename. 

Something like this, which of course doesn't work. 

{% if page.header_first.{{ the_variable }} %}


This also didn't work, as expected

{% set block_name = 'page.header_first.' ~ the_variable %}
{% if block_name %}


Any clues?
Since the dot syntax can mean a lot of different things, try to make it more clear by using the array syntax:

{% set the_variable = 'mytheme_myblock' %}

{% if page.header_first[the_variable] %}