# How do I get a list of functions defined in a module?

**URL:** <https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266>\
**Category:** New to Julia\
**Tags:** module\
**Created:** [March 24, 2019, 1:55am UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266 "2019-03-24T01:55:37Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Elmer\_Cusipuma](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/elmer_cusipuma/32/11958_2.png) [@Elmer\_Cusipuma](https://discourse.julialang.org/u/Elmer_Cusipuma)\
**Post date:** [March 24, 2019, 1:55am UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/1 "2019-03-24T01:55:37Z")

</div>

Is there a command in Julia 1.1 that lists all the methods that are available in a module?  
e.g.

```julia
module MyMod
  test1() = 1
  test2() = 2
  test3() = 3
end

```

Which would return:

` [test1,test2,test3]`

---

<div class="post-metadata">

**Author:** ![longemen3000](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/longemen3000/32/7298_2.png) [@longemen3000](https://discourse.julialang.org/u/longemen3000)\
**Post date:** [March 24, 2019, 2:04am UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/2 "2019-03-24T02:04:23Z")

</div>

I find this

```julia
names(x::Module; all::Bool = false, imported::Bool = false)

```

Get an array of the names exported by a `Module` , excluding deprecated names. If `all` is true, then the list also includes non-exported names defined in the module, deprecated names, and compiler-generated names. If `imported` is true, then names explicitly imported from other modules are also included.

As a special case, all names defined in `Main` are considered “exported”, since it is not idiomatic to explicitly export names from `Main` .

[source](https://docs.julialang.org/en/v1/base/base/#Base.names)

---

<div class="post-metadata">

**Author:** ![jiang\_ming\_zhang](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jiang_ming_zhang/32/204063_2.png) [@jiang\_ming\_zhang](https://discourse.julialang.org/u/jiang_ming_zhang)\
**Post date:** [December 3, 2023, 10:08pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/3 "2023-12-03T22:08:10Z")

</div>

I get a 354-element vector. It is not completely shown on my console.

How can I get the long list complete.

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 3, 2023, 10:12pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/4 "2023-12-03T22:12:06Z")

</div>

`show(stdout, "text/plain", somevector)`

---

<div class="post-metadata">

**Author:** ![knbrt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knbrt/32/21651_2.png) [@knbrt](https://discourse.julialang.org/u/knbrt)\
**Post date:** [December 4, 2023, 10:54am UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/5 "2023-12-04T10:54:03Z")

</div>

there is also the package [TerminalPager](https://github.com/ronisbr/TerminalPager.jl) which can be used like:

```julia
using TerminalPager
# [...]
somevector |> pager

```

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [December 4, 2023, 12:05pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/6 "2023-12-04T12:05:23Z")

</div>

I usually do `foreach(println, x)`.

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 4, 2023, 12:09pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/7 "2023-12-04T12:09:38Z")

</div>

This is not the correct answer, because names() will export all names, not only those of the functions. How can I get only the names of the functions?

---

<div class="post-metadata">

**Author:** ![knbrt](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/knbrt/32/21651_2.png) [@knbrt](https://discourse.julialang.org/u/knbrt)\
**Post date:** [December 4, 2023, 12:37pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/8 "2023-12-04T12:37:11Z")

</div>

you could just filter all the names for beeing a function or not.

```julia
filter( x -> isa(getfield(module_name, x), Function), names(module_name))

# or

filter( x -> isa(getfield(module_name, x), Function), names(module_name; all=true))

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [December 4, 2023, 12:38pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/9 "2023-12-04T12:38:54Z")

</div>

Thanks! Now using:

```julia
function list_functions()
    fncs = filter( x -> isa(getfield(Main, x), Function), names(Main))
    for (i, fn) in pairs(fncs)
        println(fn)
        if (mod(i, 10)) == 0
            println("Press enter to continue...")
            readline()
        end
    end
end

```

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 4, 2023, 3:18pm UTC](https://discourse.julialang.org/t/how-do-i-get-a-list-of-functions-defined-in-a-module/22266/10 "2023-12-04T15:18:09Z")

</div>

Check also this alternative:

```julia
function list_functions(Module)
   fncs = filter(x -> isa(getfield(Module, x), Function), names(Module))
   foreach(x -> (println.(x); Base.prompt("\nENTER")), Iterators.partition(fncs, 10))
end

```
