# Is there a way to determine whether code is toplevel?

**URL:** https://discourse.julialang.org/t/is-there-a-way-to-determine-whether-code-is-toplevel/39939
**Category:** General Usage
**Created:** [May 22, 2020, 7:32am UTC](https://discourse.julialang.org/t/is-there-a-way-to-determine-whether-code-is-toplevel/39939 "2020-05-22T07:32:00Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![yuyichao](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yuyichao/32/20_2.png) [@yuyichao](https://discourse.julialang.org/u/yuyichao)
#### Post date: [May 22, 2020, 3:25pm UTC](https://discourse.julialang.org/t/is-there-a-way-to-determine-whether-code-is-toplevel/39939/2 "2020-05-22T15:25:29Z")

</div>

Yes, you can set a `gensym` variable and test if it is indeed set on ` __module__ `.

---

_[View the full topic](https://discourse.julialang.org/t/is-there-a-way-to-determine-whether-code-is-toplevel/39939)._
