Is it possible to comment out cells in Spyder? - python

I am working in Spyder and was wondering if there is any way to comment out a whole block delimited by the common #%%. Consider the example below:
#%% Block 1
for i in range(10):
print(i)
# (other stuff)
#%% Block 2
Is it possible to comment out everything inside the Block 1 by any keybind shortcut (I'm working on Windows)?
By the way, I'm aware I can select all the lines and use Ctrl + 4 or Ctrl + 1 equivalently. I also checked this document with no success.
Thanks in advance, and sorry if this have already been asked (couldn't find any useful post myself).

(Spyder maintainer here) Unfortunately this is not possible at the moment, sorry.

Related

Collapse python comment in vs code

Not long ago, I started commenting a lot of code in python, the problem is that vs code does not offer me to reduce the comment.
I have tried single line comments and group comments but same issue..
python single line comment
python multiline program
In other languages for example C.. it offers me in the bar a button to collapse
example in C
How can comment collapsing be enabled in VS?
I tried it. I think vscode itself provides this function, but I don't know why it doesn't work for you.
As can be seen from the figure, multiline annotations can be folded.
Of course, there is no solution for your situation. We can add #region before the content, add #endregion after it.

Expected indent error after def statement

So this happens and I have tried retyping it the def statement. How can I fix this? I don't know when it started happening or why it happens but I know that I got it working once I think from restarting the program. This is python btw
https://i.stack.imgur.com/5A7kS.png
You should make sure your indentation is uniform (always 4 spaces). Starting with if Submit == "yes":, your lines have one extra space. This will be easier to do if you use a better IDE than IDLE, which will automatically highlight and label problems like this. Some good alternatives are Spyder (which is free), and PyCharm (which is free for students).

emacs Jedi disable #

I have a working version of JEDI with Emacs 24.3 on osx. The autocomplete feature is wonderful, except for when I want to comment things out! I frequently comment/uncomment portions of my code and was hoping there was a way to prevent JEDI's auto completion from coming up when I type #. Any advice or thoughts would be greatly appreciated!
edit: When I go to comment multiple lines I enter in # typically followed by DownArrow and LeftArrow, but what usually happens with JEDI enabled is this dialog pops up preventing me from moving to the following line until I make a selection:
You can try to use company-jedi for your python completion. This package doesn't have this problem.
One way to get around this issue would be to select the lines (region) you would like to comment out and hit M-;. This runs the command comment-dwim which comments out the selected region (or uncomments it, if it is currently commented out).
When used in conjunction with e.g. mark-lines which allows you to select the current line with a single key stroke, this makes for a really fast way of (un)commenting portions of your code, even if they span just one or two lines.
emacs-jedi dev here. If emacs-jedi works as you describe, then that's a bug.
But I cannot say what is wrong from the limited information I have. So, just general directions:
First, always try to reproduce the misbehavior in a clean Emacs setting, described here http://tkf.github.io/emacs-jedi/latest/#quick-try
This helps you to find out if your setting is wrong or if it is actually a bug in emacs-jedi.
Give the output of M-x jedi:show-version-info. http://tkf.github.io/emacs-jedi/latest/#jedi:show-version-info
This helps people diagnosing the problem.
This is a guess from your screenshot but it seems that you have old version of popup.el. So maybe auto-complete.el could be old one if you install them at the same time. If you don't see the problem in the clean Emacs (step 1. I mentioned above) which installs newest libraries, then updating them could solve the problem.
Update
So, I found a way to reproduce the behavior which is close to what you mentioned: https://github.com/tkf/emacs-jedi/issues/147
But as I wrote in the issue, I think it is a rare case. If you find a case which could happen very frequently, then let me know.

Sublime Text 2 :: Python code completion [duplicate]

This question already has answers here:
Sublime Text 2 auto completion popup does not work properly
(4 answers)
Closed 9 years ago.
I'm trying to get Code suggestion (the drop-down box) to suggest properly.
Right now it does not. It only suggests, more or less, identifiers and modules
that are already in the file being edited (meaning in-file scope). If, for example, I try this:
import numpy <--- numpy is not suggested as I type it.
numpy.a <--- And here, nothing that begins with 'a' is suggested.
I've implemented a raft of things suggested at various sites, including the following, but
with no success in getting correct code-complete suggestions to appear,
or sometimes to appear at all:
- Installed SublimeRope
- "use_simple_completion": true (in SublimeRope.sublime-settings)
- "auto_complete_triggers": [ {"selector": "source.python - string - comment - constant.numeroc", "characters": "."} ] (in Pyhon.sublime-settings)
- etc.
Am I missing something (of course I am :)). Appreciate the suggestions.
Sublime's autocomplete is intended to match within the current file.
If you want to have code completion based on syntactic features of the language, you have many options, but I would suggest some combination of the following:
Install the CodeIntel package (package control instructions here)
Use snippets
Install Python snippets through package control (I like sublime-unittest).
Instructions for creating your own snippets.
Hope that helps.

Is it possible to block comment Python code in TextWrangler

I am using the excellent "Learn Python The Hard Way" tutorials and i am wondering does anyone know if its possible to create block comments in it? I note from a similar question here that it does not seem to be possible in Python but that some editors have implemented methods to do it.
EDIT
I have edited the above question to provide more detail and to use the term "block comment" insted of "block quote"
Thanks
This is a duplicate question: Commenting/Uncommenting a block of Python code in TextWrangler
However, I recommend you not bother with those 9 steps and instead just download sublime text 2.
It is an excellent editor for Python (I believe that's the language its written in, in fact.) and you can accomplish what you're looking for by simply highlighting the code block and using the comment/uncomment keyboard shortcut: Ctrl+Shift+/
In textwrangler on a mac, this worked for me. Highlight the text you want to comment out. Hold down the Command Key and hit /.

Categories

Resources