how to avoid importing wrong self in eclipse python - python-3.x

I have a python pydev project.
Inside it I have classes.
When trying to use self. eclipse shows me the autocomplete for self and I naturally use it. Then I find that eclipse automatically adds this import line:
"from _pydevd_bundle.pydevd_cython import self"
How can I stop eclipse from importing this wrong 'self' ?
I have eclipse Version: 2019-03 (4.11.0)
Build id: 20190314-1200
and
Brainwy Software Ltda PyDev - Python Development Environment 7.2.1.201904261721 org.python.pydev.feature
interpreter is set to python 3.5
Thanks

Well, usually to write self in the editor you can type s and promptly press enter (if you have the default config PyDev would only show self as the single completion at that point... if you already have written self then you shouldn't really be asking to complete again -- i.e.: just press . or escape at that point and don't accept the completion).
Still, I agree that having that completion is a bit strange (it seems to be gotten from the cython analysis from a cython file in the PyDev debugger, which is a bit weird, so, please report this as an issue in: https://www.brainwy.com/tracker/PyDev/).

Related

How to use the console in Sublime Text 3

There is Hide/Show console option in "View" menu of Sublime Text 3. I tried shell, Python and Ruby commands in it but it always returns an error.
What is this console used for?
The Unofficial Documentation (which I prefer to the official documentation) states in the "Basic Concepts" section:
Sublime Text exposes its internals via an Application Programming Interface (API) that programmers can interact with using the Python programming language.
It uses an internal Python interpreter which is not the one in your system's PYTHONPATH variable. So, basic Python commands should be possible for you as it is working for me. The console output is:
...
skipping some console output before
...
plugins-loaded
>>> x = 1
>>> y = 2
>>> f = x * y
>>> print(f)
2
The purpose of the console is to interact with an API to control Sublime Text 3 internal settings:
>>> sublime.version()
'3211'
or:
>>> sublime.message_dialog("test")
which opens a clickable dialog with the text "test".
See the API reference for more information.
The console in Sublime is a window into the internal workings of Sublime in order to see the state of plugins and interact with the plugin host; the most important distinction to make is that the Sublime console IS NOT a Terminal; if you want access to arbitrary commands, you need to install a package such as Terminus to achieve that.
Most of the functionality in Sublime (including default functionality out of the box) is defined in Python plugins, and third party packages can also define Python plugins as well. The console is a window into that Python environment; if a plugin fails (like if the code is broken in some fashion), then the error that the code is generating ends up in the console.
Sublime also displays its own status into the console as well; the console contains output that indicates when plugins are being loaded and unloaded, how long it took Sublime to start up, what version you're running, etc. Any time you see an error dialog pop up, there's also a message added to the console (and in some cases errors go only to the console without being visible elsewhere).
Besides the major distinction that the console isn't a Terminal, it's also important to note that although you can enter arbitrary Python into the console and have it run, it's not meant to be your gateway to running a Python program (unless you want to evaluate single expressions and the like).
Many people fall into the trap of thinking that because Sublime uses Python for plugins that you can also use that environment to run your Python programs as well, but this is not the case. The Python environment that Sublime provides is for its own use, and is distinct from any version of Python you may or may not have installed on your computer.

Compiling pascal program in Visual Studio Code for Linux

Recently, I switched my OS to Ubuntu. I just started with collage and I have to learn pascal for my finals. But a problem occurred.
I installed Visual Studio Code and Pascal extension for it, but I am unable to run even a simple Hello World code. I wrote code, it saved automatically as .pas, but when I enter debug & run option in VSC it displays a message that says 'Open a file which can be debugged or run.', followed by 'debug' and 'run' buttons that I am unable to click and another message that says 'To further configure Debug and Run create a launch.json file.'
I am not even sure am I supposed to post questions such as this one on stackoverflow, but I sincerelly hope that someone could give me a hint on what to do. Solve this within Visual Studio Code or switch to another IDE (and which one would you recommend for Linux user) and pretend that nothing happened?
Thanks in advance.
I know this isn't an answer to "how to debug with pascal with vscode" but, perhaps you would find it easier to just use FPC / Lazarus (IDE) to do your work. While it doesn't have a dark theme, contrary to popular belief, that's not necessary to program.
The IDE is feature packed and allows for full code completion, debugging, etc... (everything you really need to do the work for school).
Additionally, you can use this open source tool to install everything you need for your platform in just a few button clicks (also allows for installing common library packages)
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases
download release for your OS
under "FPC Version" & "Lazarus Version" select trunkgit (or stable for an older version)
click the "Install/Update FPC + Lazarus" button
Have you Installed Pascal extension which is available for code to smoothly run pascal code.
If you haven't then try installing this extension using,
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install alefragnani.pascal
You can always check,
https://marketplace.visualstudio.com/items?itemName=alefragnani.pascal
to install and configure pascal in vscode.
I will direct you to the debugging page from the Visual Studio Code documentation that details how to use the debugger and configure a launch.json file. VSCode is a generic IDE so you need to give it some information about your project before it knows how to run the debugger. This is what launch.json is for.
If I could make a suggestion. When you're learning how to program, it's best to start with the basics. Write a small program in a text editor (VSCode is fine, or Vim, or Nano, or Notepad, or whatever). Save the file. Compile and run the program on the command line.
Once you put an IDE in the mix, you have to learn how to use that as well. If you're stuck on both parts, it can be hard to make progress. That said, it's good to learn how to use the IDE, and you should spend some time reading the documentation and working through some of the examples. It takes some time, but it will pay you back a thousand times when you can work more quickly.

configuring atom IDE with atom runner

I was trying to find a decent ide for python3, and atom sounded a good choice, but the atom runner is not very interactive. For example this simple code produces an error, I'm pasting a screenshot, to show the problem as it is:
Can I configure atom to execute code interactively. The way I noticed the problem was that atom runner first executes all of the code and then ONLY displays the output. Is there a fix or any packages for this?
If not, please suggest a descent and simple to use IDE for python. If there was something like the online repl.it but for offline use, it would really fit my taste.
For atom there is a package called The Terminal Plus Package: https://atom.io/packages/terminal-plus, this will open a virtual terminal that will have a the capabilities of a normal terminal. Hope I helped!
-Zeus

Python built-ins not recognized

I'm using the Redhawk IDE. I noticed when I write Python in the IDE, none of the built-ins (len(),str(),True,False,etc...) are recognized, which gives errors and causes them to be underlined in red.
However, if I install to Target SDR anyway, the component seems to function normally.
How can I get Python in the IDE to recognize built-ins so I can get rid of the faulty errors?
Erik's answer led to the solution. What worked for me is:
Window -> Preferences
PyDev -> Interpreter - Python
Remove Python interpreter
Click "New..."
Enter interpreter name ("Python" works) and select path to interpreter
By default, the top option was selected. Make sure it isn't:
Click "OK"
Click "Apply"
You should now see that the built-in functions are recognized by Python.
If you can't run any Python in the IDE, there are two possible explanations:
1. You have an incorrect Python path being set for you by Eclipse, and you will have to adjust it manually. Using this article from Opal, you can easily check that Python is in fact correctly linking to your IDE, and if it isn't you can point it in the right direction.
2. You have a broken installation of Redhawk. Sounds dubious but you can always try a fresh install.

How to run Python in komodo

I am completely new to Python and wanted to try this code from the tutorial:
istrue = 1
if istrue:
print ("be carefull!")
The code itself should be fine, but I can not find any way to execute this code inside the editor [Komodo-Edit](http://www.activestate.com/komodo-edit)
I am used to Visual Studio and QtCreator (experienced C++/Qt developer). I would expect a menu for debugging and a command such as 'start debugging' which should open a console or use a console inside the editor. I would in any case refuse to use a dos console because then the whole idea of using an IDE would be useless.
If other Python IDEs would be more useful (on windows, no costs) I could switch to another one (except for vim/emacs).
I used to use Komodo edit, but not anymore as It's more of a text editor than an IDE. I reccomend using Ninja-IDE or Eclipse with PyDev. But if you insist on using Konodo Edit, here's an option:
Go here: Toolbox > Add > New Command...
in the top field enter the name 'Run Python file' or something else. Then go to the 'command' field and enter this:
%(python) "%F"
Optionally, you could also specify key binding for fast python executing.
I tried Komodo Edit version 9 and 10. Matthias' method work for the version 9. Version 10, I couldn't see the option to choose the Interpreter.

Resources