I'm not much of an expert but here my answers. Maybe someone more knowledgeable could check/comment on the answers?
> a) Is there an equivalent to Python's doctest.testmod() in > Julia? http://docs.python.org/2/library/doctest.html[1] No. Julia comes with a rudimentary tasting framework: Base.Test and there are some more advanced ones available as packages. > b) How can I documment my code, so that calling help shows the info in > comments like Python's docstrings? There is nothing like that yet, but we're working on it: https://github.com/JuliaLang/julia/issues/3988[2] > Help on function fgen in module matematicas: > > fgen(a: int, b: int, c: int) -> '(x1: float, x2: float)' > Formula General. > > >>> from matematicas import fgen > >>> # 4x² + 3x - 1 = 0 > >>> a = 4; b = 3; c = -1 > >>> x1, x2 = fgen(a, b, c) > >>> print('x1 = {0}\n' > ... 'x2 = {1}'.format(x1, x2)) > x1 = 0.25 > x2 = -1.0 > > c) What is the difference between?: > - include > - import > - using > - require I find those a bit confusing as well, maybe because they are subtlety different from what I'm used from python. I just re-read the manual http://docs.julialang.org/en/latest/manual/modules/[3] and it helps a lot (it seems to have improved a lot since I last read it). Here as far as I understand: > - include This pastes the contents of the included file at this location. Nothing more. A file system path is the argument. > - import > - using These are similar in the sense that they make the imported/used module available in the current module. Two differences: - `import` will allow you to extent the imported functions, `using` not. - Second difference is that `using` will put the variable and functions which the module `exports` into the current namespace, `import` doesn't. Comparing to Python to Julia: import <-> import from X import name1, name2 <-> import X: name1, name2 Python's `from X import *` is similar to Julia's `using X` except that with `using` only `export`-ed objects are introduced into the current namespace. There is also the undocumented `importall`, which is similar to `using` but except that you can extent the functions it imports: https://groups.google.com/d/msg/julia-users/vQ64oPdkLbo/yD5Mi8gw7swJ[4] (I think some consider using `importall` bad style as it allows you to inadvertently extend functions from other modules.) > - require Hmm, here I struggle a bit. I think this executes the content of the file (passed as argument) in the top level scope, i.e. `Main`. What the difference is to run `include` in the top level scope, I don't know. Maybe because it searches the LOAD_PATH? > d) Does my module has to have the same name as the file ie: (Matematicas.jl > / module Matematicas)? No, there is no relation between file-name and module. Also a module can be spread over several files which are then included, see again http://docs.julialang.org/en/latest/manual/modules[5] for an example. > e) Are these homologus? > > if !isinteractive() > ...tests... > end > > if __name__ == '__main__': > ...tests... No, I don't think so: the first is run whenever the session is not interactive. The second is run when python is called to process that particular file as top-level file (i.e. not imported by other files). In Julia this would be done as: if current_module()==Main ... end but that doesn't seem to be used as much as in Python. At least I haven't seen it yet. > f) Do I have to export fgen to be able to import it from another module? Or > when should I use export? If you want to be able to call fgen without fully qualifying it as Matematicas.fgen, then `export` it inside the module and `using` it where you want to use it. Generally, what you think is the public interface to your module is exported. > I know there are many noob questions, sorry, ...but I have no hurry! ;-) No worries.
