Reputation: 233
Python has dict, doc, init and so on. Is there something like that in Julia? How can I know names of functions of Julia packages?
Upvotes: 2
Views: 224
Reputation: 493
In addition to the function names
(e.g. names(Gadfly)
), which is used for modules. If you want to get all the attributes of the object, there are two functions for that:
fieldnames
- returns a list of the fields for the object
e.g.struct Point
x
y
end
> propertynames(Point(2,3))
(:x, :y)
propertynames
- returns a list of all the properties for the object. Usually the same as fieldnames plus user-defined properties (in most cases, you should use this function instead of fieldnames
)
Upvotes: 6
Reputation: 69869
Use the names
function to get a list of all names exported by a module (as this is what I assume you are looking for). Note that the list will in particular include: functions, types, variables, and other modules. Here is an excerpt from its docstring giving you more details:
names(x::Module; all::Bool = false, imported::Bool = false)
Get an array of the names exported by a
Module
, excluding deprecated names. Ifall
is true, then the list also includes non-exported names defined in the module, deprecated names, and compiler-generated names. Ifimported
is true, then names explicitly imported from other modules are also included.
Because of the Julia design you should be aware of two issues:
Upvotes: 5