Config IPython show warning once - ipython

I'm trying to config IPython show warning message once with module warnings, the simple code as below
import warnings
warnings.simplefilter('once', RuntimeWarning)
def x()
warnings.warn('xxx', RuntimeWarning)
x()
C:\Program Files (x86)\Python37-32\Scripts\ipython:2: RuntimeWarning: xx
x()
C:\Program Files (x86)\Python37-32\Scripts\ipython:2: RuntimeWarning: xx
as you can see the warning always show, if I use warning.simplefilter('ignore', RuntimeWarning) then the warning message will be hide. and also tried in python terminal, it work as expected.
so is IPython doesn't support show warning message once? or is there anything wrong?
Thanks in advance.

Related

Pylint Error: Attempted relative import beyond top-level package

Here in VSCode whenever I write the following line from . import dispatcher pylint always gives error statement saying Attempted relative import beyond top-level package.
But when I run the module using this command: python -m src.train the program runs without flashing any error. Here is the screenshot from the VSCode editor:
Does someone know who to solve this thing in VSCode?
Just add an empty __init__.py file of the folder that contains your dispatcher.py file, then all the .py files under the folder, as whole, should be recognized as a package. And the lint error should dismiss.

error: the following arguments are required: --path An exception has occurred, use %tb to see the full traceback.

project on https://github.com/linouk23/NBA-Player-Movements. Could you please let me know how to execute this project? I'm new to python. It'll help me to kick start my work on project. I'm executing my project on Spyder and installed all necessary libraries. I'm getting error as
usage: main.py [-h] --path PATH [--event EVENT]
main.py: error: the following arguments are required: --path
An exception has occurred, use %tb to see the full traceback.
For windows:
Open the extracted folder and press "shift + right click" and from there "Open command window here".
In cmd enter python main.py
Well, I tried in Jupyter Notebook and it failed, then I copied it in a .py file and run (Ubuntu) in terminal ,it worked.
I don't know how to solve the problem but I can 'avoid' this.
For the ones who are receiving this error, another thing to check is the way you are passing the arguments. Arguments are passed by adding two leading hyphens. So, when the error says
following arguments are required: example_arg
your code should be
parser.add_argument('--example_arg', 'arg1'). Note the two leading hyphens --

Is it possible to run rascal programs from the command line?

I know how to run rascal code from within eclipse and how to use the REPL, but I don't know how I can run a rascal file (or group of rascal files) as a program from the command line.
When I try the following, I get a parse error:
$ java -Xmx1G -Xss32m -jar rascal-shell-stable.jar mymodule.rsc
Version: 0.7.2.201501130937
Parse error in cwd:///mymodule.rsc from <1,11> to <1,12>
The contents of mymodule.rsc:
module mymodule
println("hello world");
What am I doing wrong?
Well, your mymodule.rsc is actually syntactically incorrect and will also give parse errors in the Eclipse IDE. Here is an improved version:
module mymodule
import IO;
value main(list[value] args) {
println("hello world");
}
Bonus: you should also add import IO; to make the println function available.

Dart static type errors (instead of just warnings) in Eclipse

I am using the Dart plugin for Eclipse (not the standalone Dart Editor).
How do I configure the project/build so that static type warnings appear as errors in the Eclipse "Problems" tab? For example, this line of code actually compiles, which seems ludicrous:
int newtodo = new LIElement();
Running dartanalyzer at the command line gives an error, as desired:
dartanalyzer foo.dart
But instead of having to run dartanalyzer at the command line (or discovering them at runtime), I would like to have these errors reported on-the-fly in Eclipse.
If this doesn't produce a warning this is a bug according to this discussion new user question. type warnings as errors in Eclipse
(Also initiated from #Justin M. Keyes)

"import as" leads to unresolved import error, "from .. import" does not

I'm trying to write some plugins for the irc bot supybot with eclipse/pydev. Pydev gives me errors about unresolved imports on supybot-modules/packages (e. g. import supybot.utils as utils), but works ok on e. g. "from supybot.commands import *". So I guess I set up dydev correctly, as it finds the wanted modules. The problem must be in pydev/eclipse, as the bot works correct and in eric5 I get also no errors about that.
Removing the interpreter and setting it up didn't help. Any other ideas on how to fix this? System: Arch Linux, Eclipse Juno, PyDev 2.7.1, wanted (and set up) python interpreter is 2.7, supybot is installed in site-packages for Python 2.7.
Edit: Just noticed: PyDev doesn't mark the "from ... import *" as error, but if I use functions imported from there I get an error on that function.
Code sample:
[...]
import supybot.utils as utils
from supybot.commands import *
[...]
wunsch = wrap(wunsch, ['text', 'now'])
[...]
Error on the first line: Unresolved import: utils
Second line gets no error nor warning
Error on 3rd line: Undefined variable: wrap
But 'wrap' is a function declared in supybot.commands
Run import supybot; print supybot.__path__ to get the path to the supybot package. PyDev may be importing the wrong one (for example if you use a folder called supybot in your workspace).