如何列出tclsh实例中加载的所有命名空间?
Chenz
答案 0 :(得分:6)
尝试从TCLer的Wiki
运行此proc proc listns {{parentns ::}} {
set result [list]
foreach ns [namespace children $parentns] {
eval lappend result [listns $ns]
lappend result $ns
}
return $result
}
当我运行它时,我得到以下输出:
% listns
::platform ::activestate::teapot::link ::activestate::teapot ::activestate ::tcl
::clock ::tcl::info ::tcl::dict ::tcl::tm ::tcl::mathop ::tcl::unsupported ::tcl
::mathfunc ::tcl::chan ::tcl::string ::tcl
%
因此,要获得所有名称空间,您只需要这样做:
set all_namespaces [concat [listns] "::"]