# I can use \`getfield(Module, :functionname)\` to grab a variable in \`Module\`, e.g. \`

**URL:** https://discourse.julialang.org/t/i-can-use-getfield-module-functionname-to-grab-a-variable-in-module-e-g/55029
**Category:** General Usage
**Created:** [February 10, 2021, 10:27pm UTC](https://discourse.julialang.org/t/i-can-use-getfield-module-functionname-to-grab-a-variable-in-module-e-g/55029 "2021-02-10T22:27:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![BridgeBot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bridgebot/32/21491_2.png) [@BridgeBot](https://discourse.julialang.org/u/BridgeBot)
#### Post date: [February 10, 2021, 10:27pm UTC](https://discourse.julialang.org/t/i-can-use-getfield-module-functionname-to-grab-a-variable-in-module-e-g/55029/1 "2021-02-10T22:27:56Z")

</div>

I can use `getfield(Module, :functionname)` to grab a variable in `Module`, e.g. `Main`: but can I do the same for a local variable in a function?

Note that the original poster on Slack cannot see your response here on Discourse. Consider _transcribing the appropriate answer back to Slack_, or pinging the poster here on Discourse so they can _follow this thread_.  
[(Original message :slack:)](https://julialang.slack.com/archives/C6A044SQH/p1612995814498200?thread_ts=1612995814.498200&cid=C6A044SQH) [(More Info)](https://github.com/JuliaCommunity/SlackBridge)

---

<div class="post-metadata">

### Author: ![tchr](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tchr/32/15138_2.png) [@tchr](https://discourse.julialang.org/u/tchr)
#### Post date: [February 10, 2021, 10:29pm UTC](https://discourse.julialang.org/t/i-can-use-getfield-module-functionname-to-grab-a-variable-in-module-e-g/55029/2 "2021-02-10T22:29:14Z")

</div>

Answer from Chris de Graaf:

> Check out `Base.@locals` , I think that’s the best you’ll find
