# Overwriting a global variable with keyword result

**URL:** <https://forum.robotframework.org/t/overwriting-a-global-variable-with-keyword-result/5781>\
**Category:** Robot Framework\
**Created:** [2 June 2023 09:47 UTC](https://forum.robotframework.org/t/overwriting-a-global-variable-with-keyword-result/5781 "2023-06-02T09:47:59Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohdl](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/mohdl/32/2575_2.png) [@mohdl](https://forum.robotframework.org/u/mohdl)\
**Post date:** [2 June 2023 09:47 UTC](https://forum.robotframework.org/t/overwriting-a-global-variable-with-keyword-result/5781/1 "2023-06-02T09:47:59Z")

</div>

Hey,

So I have the following case with Some Global Variable that I want to overwrite in one of my tests with a result that is being returned from a keyword.

at first I used this  
${Some Global Variable} = Some Keyword

but soon realized that my original variable is being shadowed and not overwritten, so I adjusted it like this

${tmp} = Some Keyword  
Set Global Variable ${Some Global Variable} ${tmp}

which sets my global variable to the correct value but seems a bit clumsy, so is there a better way to do this?

Thanks in advance

---

<div class="post-metadata">

**Author:** ![damies13](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/damies13/32/623_2.png) [@damies13](https://forum.robotframework.org/u/damies13)\
**Post date:** [2 June 2023 10:21 UTC](https://forum.robotframework.org/t/overwriting-a-global-variable-with-keyword-result/5781/2 "2023-06-02T10:21:33Z")

</div>

Hi Mohamed,

```python
${tmp} = Some Keyword
Set Global Variable ${Some Global Variable} ${tmp}

```

Doing this is the correct way 👍.

Unless you use a `Set something Variable` keyword then all variables are local scope by design it’s explained here → [Variable scopes](https://robotframework.org/robotframework/latest/RobotFrameworkUserGuide.html#toc-entry-324)

Dave.
