Question: I have dumped a couple of variables I need to store in a json object as shown here-

```
def write_json():
    variable = {}
    variable['p_id'] = p_id
    variable['s_id'] = s_id
    variable['t_id'] = t_id
    variable['b_start'] = b_start
    variable['b_end'] = b_end
    variable['wsp_after'] = wsp_after
    variable['h_id'] = h_id
    variable['word'] = word
    variable['norm_word'] = norm_word
    variable['lemma'] = lemma
    variable['pos'] = pos
    variable['ner'] = ner
    variable['dep'] = dep
    variable['quote'] = quote
    variable['ch_id'] = ch_id

    with open('variable.json', 'w') as fp:
        json.dump(variable,fp, sort_keys = True)

```

I want to write a piece of code that would automatically get these variables assigned appropriately as would happen if you wrote from 'X.py' import \*

This is what I tried-

```
def get_variables():
    with open('variable.json', 'r') as fp:
        variable = json.load(fp)
    for key in variable:
        global key
        key = variable[key]

```

However, when I tried to print the original value-

```
    print t_id
NameError: name 't_id' is not defined

```

What do I need to do to achieve what I want rather than cumbersomely typing 

```
t_id = variable['t_id']
.
.
.

```

For every variable I have dumped?

Answer: 
Try the following code: 

```
public static void animate(RecyclerView.ViewHolder holder, boolean direction) {
    AnimatorSet animatorSet=new AnimatorSet();
    ObjectAnimator animator_Y=ObjectAnimator.ofFloat(holder.itemView,"translationY",direction ? 100 : -100,0);
    animator_Y.setDuration(1000);

    ObjectAnimator animator_X=ObjectAnimator.ofFloat(holder.itemView,"translationX",-20,20,0);
    animator_X.setDuration(1000);

    animatorSet.playTogether(animator_X,animator_Y);
    animatorSet.start();
    Log.e("animation","animation running");
}

```

As mentioned in the android documentation for [ObjectAnimator](https://developer.android.com/reference/android/animation/ObjectAnimator.html)

> 
> This subclass of ValueAnimator provides support for animating properties on target objects. The constructors of this class take parameters to define the target object that will be animated as well as the name of the property that will be animated. Appropriate set/get functions are then determined internally and the animation will call these functions as necessary to animate the property.
> 
> 
> 

So, the problem in your code was that the `ObjectAnimator` could not find properties `TranslationX` and `TranslationY` in your target object that can be animated.
try by maintaining reference of your row layout parent root xml tag into holder and use that instead of using holder.itemview.