Julia中已加载/导入的软件包的列表 [英] List of loaded/imported packages in Julia

查看:102
本文介绍了Julia中已加载/导入的软件包的列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取Julia会话的已导入/已使用软件包的列表?

How can I get a list of imported/used packages of a Julia session?

Pkg.status()列出所有已安装的软件包.我对通过using ...import ...

Pkg.status() list all installed packages. I'm interested in the ones that that were imported/loaded via using ... or import ...

似乎whos()包含相关信息(名称以及是否为模块). whos()的输出可以捕获到变量中吗?

It seems that whos() contains the relevant information (the names and whether it is a module or not). Can the output of whos() be captured in a variable?

推荐答案

using Lazy
children(m::Module) =
  @>> names(m, true) map(x->m.(x)) filter(x->isa(x, Module) && x ≠ m)

children(Main)然后将为您提供当前已加载模块的列表.

children(Main) will then give you a list of modules currently loaded.

我在这里将Lazy.jl用于画眉宏(@>>),但是您可以不那么容易地重写它:

I used Lazy.jl here for the thrush macro (@>>), but you can rewrite it without easily enough:

children(m::Module) =
  filter(x->isa(x, Module) && x ≠ m, map(x->m.(x), names(m, true)))

或者,您可以将&& x ≠ Lazy添加到filter以避免包含它.

Alternatively you could add && x ≠ Lazy to the filter to avoid including it.

这篇关于Julia中已加载/导入的软件包的列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆