pydev - can someone please explain these errors - python

I am developing using PyDev in Eclipse. I have put in some comments in my code. I get wavy red lines underneath certain words. The program runs fine and there are no warnings mentioned. So what is the meaning of these wavy lines.
e.g.
#!/usr/bin/python - I get the line under usr and python
# generated by accessing registry using another script written in VBScript.
# The scripts can do the follwing things.
- I get wavy lines under the words registry and following.
I need these comments as I may run the module on its own later.
Thanks for the help.

Neil speaks the truth, except for telling you to turn it off -- spell check in comments is quite helpful -- those who come after will thank you for ensuring they can read your comments without trying to decode random spelling errors.
The lines are simply pointing out words your IDE thinks are spelled wrong. I don't know why it doesn't understand "registry", but you have, in fact, misspelled "following" (as "follwing"). Fix the latter, ignore the former (or add it to the dictionary, don't remember if there's a convenient mechanism for that There is! See Macke's helpful comment below.).

Might be this is just a spellchecker. You have a typo "follwing" instead of "following".

Related

How to disable squiggly lines underline in VSC 1.49.2?

Please help, it's driving me nuts. I tried following another older stack overflow post and it didn't work. I just declare a new variable and I already get squiggly line - what an annoying feature. Using python by the way on VSC.
Something like this:
My json.settings look like this:
Based on the information you provided, I reproduced the problem.
The reason is that Python's code analysis tool Pylint detects that the variable "words_to_remove" is not used, so it displays "Pylint(Unused variable)".
Solution:
Complete the code. for example:
Turn off the prompt of Pylint.
1). Close the "Unused variable" prompt of pylint:
Please use "python.linting.pylintArgs": ["--disable=W0612"], in settings.json:
2). Close Pylint.
Use "python.linting.enabled":false , in settings.json.
In addition, Pylint is an excellent Python code analysis tool. It will provide good suggestions on the format and syntax of the code we edit and it does not affect the execution of the code.
Therefore, if you want to turn off Pylint related prompts to remove the wavy lines, it is better to set it off after the code can be executed.

Under spf13-vim, how to jump to next item in the loop

I am new to spf13-vim configuration. I have a basic problem; for example, when I am writing a python script, if I type "for" in vim console, I could see:
1 for item in <`2:items`>:
2 <`0`>
Then I can type any variable on "item", but I couldn't figure out how to jump to the next item, "<2:items>". How could I do that?
The direct answer to your question is: press Tab.
This feature is most certainly not provided by spf13 itself: it is provided by a snippet-expansion plugin that comes with spf13. Maybe it's SnipMate? Maybe it's UltiSnips? Maybe another one? Who even knows? You could simply look up up the documentation of that plugin but you can't, because you don't know what plugins you have.
Well, you are supposed to know what the plugins you add to your config that you manage yourself do and do not. But you don't, because you gave away that responsibility to someone else and you end up with a black box that contains and does things you have no idea about.
And the best part is that you don't even ask for help to the author/maintainer of that crappy distribution. They lured you into installing their stuff and giving control up, they are the ones who should help their poor, misled, users.
If you are serious about using Vim, drop spf13 immediately and take care of your configuration yourself.
If you don't care about doing things the right way, use another editor.
Press Ctrl+k to jump to the next item.

Virtual brackets in Python

(Warning: Potential flame-war starter. This is however not my goal, the point here is not to discuss the design choices of Python, but to know how to make the best out of it).
Is there a program, script, method (Unix-based, ideally), to display "virtual" brackets around blocs of code in Python, and to keep them where they are so that the code can still be executed even if indenting is broken ?
I realize that Python only uses indentation to define blocks of code, and that the final program may not contain brackets.
However, I find it very annoying that your program can stop functioning just because of an unfortunate and undetected carriage-return.
So, ideally I would be looking for a plugin in a text editor (kate, gedit...) that would:
Display virtual brackets around blocks of code in my Python program
Keep them in place
Generate dynamically the "correct" Python code with the indentation corresponding to where the brackets belong.
(no flame-war, please !)
I used an editor that does code rollups and understood Python syntax, then I looked for rollups that are in unexpected locations. I don't remember if Kate does that. It's not obvious that there is an issue, but it makes it easier when you are looking for an issue.

How to avoid the \xc2 character or in my code snippets?

I've just started a coding blog, and I'm using the SyntaxHighlighter Evolved Wordpress plugin for Syntax Highlighting of my snippets.
I've just about finished writing a Pythonic post, and wanted to test out my code snippets before publishing.
If you double click code from inside my snippets, the plugin will stop highlighting the code, allowing you to select it as plain text. However, if I copy and paste some Python code from my snippets, it includes \xc2 or chracters in. This causes Python to winge about the encoding:
SyntaxError: Non-ASCII character '\xc2' in file ex2.py on line 3, but no encoding declared; see http://www.python.org/peps/pep-0263.html for details
I don't particularly want to be declaring encodings for every single Python snippet I write - and I don't even know if this will solve the issue.
The best solution would of course to be to get my plugin to not use characters in the plain text version. Or would it?
Does anyone have any ideas as to how I can get around this issue?
Ah, got it. Just a bit of poking around in the plugin's source fixed this issue for me...
If you beautify the syntaxhighlighter3/scripts/shCore.js file, then you can see there is a config variable, which includes:
space: " "
All I had to do was change it to space: " " and repack it.
I ran into this problem when python code had been copied from skype. Since I use vim to edit, I went ahead and found all of these by doing this:
:hls
/<space>
This shows where these odd space characters aren't because they're not highlighted.
Yank one of the characters which will store it into register 0.
Use the substitute command and use <ctrl-R> <0> to paste that character into the command prompt.
:%s/<ctrl-R><0>/ /g
It will look like
:%s/ / /g
but when run, it will correct the problem.
NBSP isn't considered whitespace for the purpose of indentation anyways, so you should take a look at what the pre select user script does and mimic it.

introspective code completion with VIM? ... or other lightweight editor with this feature?

I've been all over the web trying to find a way to get VIM to have code completion similar to PyDev. It doesn't seem like it is possible!
-I have tried to use the omnicompletion suggested at this link: http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ .
-I have tried several addons to alleviate the problem, none work.
The "omnicomplete" functionality is NOT what I am looking for. It just takes all the words in the file you are working on and uses those to try and complete what I am doing. For example if I wrote:
import numpy
a_single_array = range(100)
np.a#[then I hit cntrl+n to code complete]
It would spit out "a_single_array" as a possible completion -- but that is absurd! That is not a valid completion for "numpy.a ..."
What is the issue here? All the addon would have to do is run a dir(work you want to find) from the folder you are in and then filter the output! This cannot be that difficult! (I suppose you would also have to read the file you are currently editing and filter that as well to take note of name changes... but that's pretty much it!)
Speaking of how easy it would be... if there isn't anything already made, I was thinking of writing the script myself! Any guides on how to do THAT?
No, the omni completion functionality is EXACTLY what you are looking for.
You are using <C-n> instead of <C-x><C-o>:
type <C-n> & <C-p> to complete with words from the buffer (after and before the cursor respectively)
type <C-x><C-o> to complete method/properties names
It's specifically explained in the article you linked:
In V7, VIM introduced omni completion – given it is configured to recognize Python (if not, this feature is only a plugin away) Ctrl+x Ctrl+o opens a drop down dialog like any other IDE – even the whole Pydoc gets to be displayed in a split window.
Ctrln is insert-completion.
Ctrlx Ctrlo is omni-completion.
I remap omnicompletion to CtrlSpace:
inoremap <C-Space> <C-x><C-o>
You could also try SuperTab.
I have no idea about the various completion options for Python in Vim. But if you want to roll your own you'd be well advised to study and modify one of the existing ones, like this:
http://www.vim.org/scripts/script.php?script_id=1542
Also, if all your omnicompletion is doing is listing words in current file then you don't have it set up properly for Python-specific completion. . . . Not sure how good the specialized Python completion systems get, but they certainly does compete based on Python units external to your current file. . . .

Categories