This is my code:
Program Module_in_module
Use Module_collection
Implicit none
! Something...
End Program Module_in_module
Module Module_collection
Use Number_01
Use Number_02
End Module Module_collection
Module Number_01
Implicit none
! Something......
End Module Number_01
Module Number_02
Use Module_collection
Implicit none
! Something......
End Module Number_02
I have an intention to use module Module_collection like one module which use all rest modules in the project. For example, if I want to use, in some other module, which is already in Module_collection, all modules from project with Use Module_collection i got this message:
Fatal Error: Can't open module file 'module_collection.mod' for reading at (1): No such file or directory
Is there any equivalent for Only: Some_varable which can be used for excluding module with using Module_collection (Use all others modules in project but only exclude just, in this case, Module Number_02?
Now you tell us
I also got this message: it seems you have a circular dependency in
Fortran files. Check your USE or INCLUDE statements.
and your error is blindingly obvious. The module module_collection uses module number_02 and module number_02 uses module module_collection. Since Fortran requires that a module be compiled before it is referenced (in a use statement) and since there is this circular dependency the compiler can't continue.
Resolve the circular dependency. It looks a bit odd that the the collector is referenced by one of its collection.
I expect this is a duplicate of another question I haven't found yet.
Related
import MySQLdb
try:
dbcon = MySQLdb.connect(host=host_name, user=user_name,
passwd=password, db=db_name)
except MySQLdb.Error:
pass
getting this pylint warning
Module 'MySQLdb' has no 'Error' member (no-member)
The Best:
Using extension-pkg-whitelist option:
A comma-separated list of package or module names from where C extensions may be loaded. Extensions are loading into the active Python interpreter and may run arbitrary code
--extension-pkg-whitelist=_mysql
PyLint parses (by default) the source files, but in Python the shape of a module can change at runtime from the shape defined in the source file. This option tells PyLint to actually import the specified module, and use the runtime definition.
Note that since the MySQLdb package wraps a C extension, you have to pass the name of the C extension (_mysql) instead of the package name (MySQLdb). (source)
Not Bad:
Using unsafe-load-any-extension option
Allow loading of arbitrary C extensions. Extensions are imported into the active Python interpreter and may run arbitrary code.
--unsafe-load-any-extension=yes
You could use the unsafe-load-any-extension option, but that would load every available extension, with its' (potentially dangerous) initialization code. extension-pkg-whitelist is safer, because it only loads the specified modules.
The Worst:
Using disable option
# pylint: disable=no-member
It doesn't really solve the issue, but only makes PyLint silent.
Thanks to #PCManticore, the maintainer of PyLint. Here's the comment of the maintainer.
Thanks to #ZevSpitz, the contributor of the best answer and this not bad answer.
It may help to use the --extension-pkg-whitelist option:
--extension-pkg-whitelist=_mysql
pylint parses (by default) the source files, but in Python the shape of a module can change at runtime from the shape defined in the source file. This option tells pylint to actually import the specified module, and use the runtime definition.
Note that since the MySQLdb package wraps a C extension, you have to pass the name of the C extension (_mysql) instead of the package name (MySQLdb). (source)
You could use the unsafe-load-any-extension option, but that would load every available extension, with its' (potentially dangerous) initialization code. extension-pkg-whitelist is safer, because it only loads the specified modules.
I'm following the instructions in the Coinbase API guide Coinbase Guide The first line of the code is to simply load the Coinbase library:
from coinbase.wallet.client import Client
I'm using IDLE as the IDE. If I work on a file with no extension (e.g. simply called 'coinbase') then the examples in the guide work fine.
If I work on a file with the standard Python extension (e.g. 'coinbase.py') it does not load the Coinbase library and errors out! The error message is:
ImportError: No module named wallet.client
I think this may not necessarily Coinbase related, and perhaps I'm doing something fundamentally wrong. Answers appreciated.
Remember that all python files are seen by python as modules.
So when you write a script called coinbase.py, python will see it as a module and let you import it with import coinbase. Doing so you are shadowing the real coinbase module that you meant to import, hence the error.
To fix the problem simply avoid calling your files with existing module names (unless of course you intend to shadow them).
How can I find out where in the C++ source code of node.js the JavaScript object gets defined which I can access through process.binding('eval')? - I already found out that it's in /src/node_script.cc in this special case, but: How can I know where I can find that module just when I just take a look on the /src/ directory overview? I don't want to step through all the files in /src/ in order to look for a module.
Where can I find some deep going information about the internals of process.binding()s?
Thanks.
I was looking for the same myself today. I cannot guarantee that there isn't more to it, but this is what I discovered.
src/node_extensions.h contains a list of built-in modules, defined like:
ITEM(node_module_name)
where module_name is the name of the module (obviously)
You can find out which file defines that module by searching for which file has a line that starts with
NODE_MODULE(node_module_name,
So, to find the file that defines the 'evals' module for process.bindings:
$ grep "NODE_MODULE(node_evals" src/*.cc
src/node_script.cc:NODE_MODULE(node_evals, node::InitEvals)
I would like to give two .ml sources files the same name in different directories in my source tree, but the OCaml documentation states that the a file A.ml is exported as a toplevel module A = struct ... end. If I have two files X/A.ml and Y/A.ml, how can I refer to them both from B.ml?
Modules can contain modules, i.e. you can have a hierarchy of modules.
From the B.ml point of view, you can see two modules named X.A and Y.A .
They can even both have a function named foo, those functions would be seen as X.A.foo and Y.A.foo .
Beware that if you open both modules X and Y, the module A from Y will hide the module A from X.
That was from the namespace point of view. Now, about the source tree.
One way would be to have those files:
x.ml
X/a.ml
y.ml
y/a.ml
The file x.ml is automatically generated and contains just this:
module A = struct
(*The contents of x/a.ml is included here*)
end
Likewise for y.ml
There are several preprocessors able to include a file: cpp, camlp4, camlp5, camlmix...
This set of automatically generated files (and regenerated each time the source changes) is not very satisfiying, I will look at other answers.
You can also have a look at ocamlc -pack, but when I tried it a long time ago there was a problem with ocamldoc unable to have x/a.ml and y/a.ml . So check this before you settle on a tool.
You cannot link modules with the same name into the same program. For example, extensions to the standard library, such as Batteries and Core, are forced to give standard modules a different name. In Batteries, the List module is called BatList. Then, they provide a wrapper module Batteries, within which the module is renamed with by doing module List = BatList. The overall path to this module is Batteries.List, so there is no clash with the Standard Library's top level List. Finally, the recommended way of using Batteries and Core is to do open Batteries and open Core, thereby giving you access to their additional list functions under the module name List.
Thus the only option is to rename your modules, but you can do this in two ways:
Change the base names of the modules, e.g. call them A and B.
Put the modules under another module, e.g. name them X.A and Y.A. If you want to keep your current directory structure, you can use OCaml's -pack option. Personally, I find this option too restrictive and always end up doing manual packing, i.e. the technique described above used by Batteries and Core.
in file testmodule.ml
module TestModule =
struct
type my_type = MyType1 | MyType2
end
How can I use TestModule in top-level?
after "ocamlc -c testmodule.ml" (this generated testmodule.cmo/cmi)
I tried "open TestModule", but error "unbound module TestModule" occured.
Objective Caml version 3.10.0
# open TestModule;;
Unbound module TestModule
then, I tried making top-level with that module. but...
indi#www:~/std/toq$ ocamlmktop -o mytop testmodule.ml
indi#www:~/std/toq$ ./mytop
Objective Caml version 3.10.0
# TestModule.MyType1;;
Unbound constructor TestModule.MyType1
# open TestModule;;
Unbound module TestModule
What can I do for using my TestModule???
The directives you can use in the toplevel to that effect are listed in the manual.
You can try #use "testmodule.ml";;, or, alternatively #load "testmodule.cmo";; after having compiled your module.
As huitseeker mentioned, you can use #use "testmodule.ml";;. However, this will make the module Testmodule avialable, and your TestModule module is actually Testmodule.TestModule. .cmo files (generated from .ml files) define a module whose name is that of the CMO with the first letter capitalized. Therefore, I would omit the module TestModule ... part of your code, and simply put your code in a file called testModule.ml. You can then compile it and use #use "testModule.ml";; to access the module.
Tu summarize: a few minor details all conspired together against you :-)
First, as mentioned previously, you need to load the code into the toplevel with either #use "testmodule.ml";; for source files or #load "testmodule.cmo";; for compiled files, or to use ocamlmktop. This explains why your first attempt did not work: you did not load the code.
Second, you defined module TestModule in a file called testmodule.ml. Keep in mind that the file defines its own module based on its name. So, in order to access your module, you need to write Testmodule.TestModule. This explains why your second attempt did not work: the code was loaded but had an unexpected name.
You might wish to remove the TestModule definition and rename the file to testModule.ml (or the perhaps more idiomatic test_module.ml).