Title: Variables in python regex? Print statements in airflow?
Tags: python;regex;airflow
Question: I am working on a simple program to see if a file "test-2018-06-04-1358.txt" exists in a directory using airflow. I have two issues. 

A) I want to use the variable datestr in my regex. Not sure how to do that. 

B) Secondly, Where does my print(filename) show up in airflow UI? I checked my view log but nothing showed up.

```def checksFile():   
        d = datetime.today()-timedelta(days=1)
        datestr = '{:%Y-%m-%d}'.format(d)
        for filename in os.listdir('/mnt/volume/home/aabraham/'):
            match = re.search('(test)-(2018-06-04)-(\d+)(\.txt)', filename)
            print(filename)
        if not match:
            raise AirflowException("File not Found")
```

Comment: If you find you are not getting the answers you want, this could be a good question to split into 2.  1 for the regex, and 1 for airflow.  I could see a regex pro not wanting to answer since they don't know airflow or vice versa.

Comment: will keep in mind, thanks

Here is the accepted answer: You cannot use ```print``` in the same fashion as in the console.

To see logging entries in the ```Log``` page use ```logging.info```. Maybe you need to ```import logging```.


Here is another answer: To answer the regex question, just add the strings together:

```match = re.search('(test)-(' + datestr + ')-(\d+)(\.txt)', filename)
```

This will only work if ```datestr``` doesn't contain any regex literals.

Comment for this answer: @sniperd Can he? He doesn't have 15 rep.
Comment for this answer: @friendly1358 you can upvote both answer though, and that would help the people who answered :)
Comment for this answer: @MegaIng ooopps!  You are right.  I'll do it by proxy then :)
Comment for this answer: couldn't  also mark this as correct, but this works. thank you!

{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 2, 'CommentCount': 2, 'ContentLicense': 'CC BY-SA 4.0', 'CreationDate': '2018:00:06/06/18', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<python><regex><airflow>', 'Title': 'Variables in python regex? Print statements in airflow?', 'ViewCount': 487, 'id': 50723581, 'user_AboutMe': None, 'user_AccountId': 13689541.0, 'user_DisplayName': 'friendly1358', 'user_Reputation': 57.0, 'user_Views': 8.0, 'user_id': 9877725.0}}