# Dynamically assign keywords when using annnotate\_rows()

**URL:** <https://discuss.hail.is/t/dynamically-assign-keywords-when-using-annnotate-rows/1037>\
**Category:** Hail Query & hailctl\
**Created:** [August 6, 2019, 10:11pm UTC](https://discuss.hail.is/t/dynamically-assign-keywords-when-using-annnotate-rows/1037 "2019-08-06T22:11:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![stecast](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/stecast/32/298_2.png) [@stecast](https://discuss.hail.is/u/stecast)\
**Post date:** [August 6, 2019, 10:11pm UTC](https://discuss.hail.is/t/dynamically-assign-keywords-when-using-annnotate-rows/1037/1 "2019-08-06T22:11:35Z")

</div>

I am attempting to annotate rows in a matrix table using a large number of annotations. In order to do this I am looping through a set of numbered annotations. I am running into an issue where I’d like to be able to assign keywords for these annotations dynamically when using mt.annotate\_rows(), for example:

> for i in range(1, 101):  
> an\_table = hl.import\_bed(“an”+str(i)+“.bed.bgz”)  
> mt = mt.annotate\_rows(‘AN\_’+str(i) = an\_table[mt.locus][‘target’])

However I get the error:

> keyword can’t be an expression

Is there a way to dynamically assign keywords using a e.g. a string expression? Thank you for any insight.

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [August 6, 2019, 11:00pm UTC](https://discuss.hail.is/t/dynamically-assign-keywords-when-using-annnotate-rows/1037/2 "2019-08-06T23:00:05Z")

</div>

keyword args in Python can be passed as a dictionary using `**`:

```python
>>> def foo(**kwargs):
        print(kwargs)

>>> foo(a=5, b=7)
{'a': 5, 'b': 7}

>>> foo(**{'a': 5, 'b': 7})
{'a': 5, 'b': 7}

```

---

<div class="post-metadata">

**Author:** ![tpoterba](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/tpoterba/32/61_2.png) [@tpoterba](https://discuss.hail.is/u/tpoterba)\
**Post date:** [August 6, 2019, 11:00pm UTC](https://discuss.hail.is/t/dynamically-assign-keywords-when-using-annnotate-rows/1037/3 "2019-08-06T23:00:11Z")

</div>

need to put this in the docs.

---

<div class="post-metadata">

**Author:** ![stecast](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.hail.is/stecast/32/298_2.png) [@stecast](https://discuss.hail.is/u/stecast)\
**Post date:** [August 7, 2019, 4:00pm UTC](https://discuss.hail.is/t/dynamically-assign-keywords-when-using-annnotate-rows/1037/4 "2019-08-07T16:00:31Z")

</div>

This answered my question perfectly, thank you! I learned something new about python too!
