When making a method in Eclipse using Python, is there a way to jump directly to next line, indented, after making input arguments? Instead of having to press end and enter, I keep missing that end key.
def _run_to_the_hills(self|):
Yes, you can use Shift+Enter for that (which in Eclipse means: move cursor to end of line and do a new line there).
I also recommend you read: http://pydev.blogspot.com.br/2014/03/mastering-writing-code-on-pydev.html at least once -- this is the first tip there, but there are other nice things there that you should know about too ;)
Related
I have installed spacemacs, and there's a very annoying behavior I need to disable to make it usable. Every time I define a new function, the ":" at the end of the line is automatically typed for me, but the cursor is not forwarded to after it, so when I type what I mean, I end up with a function like:
def foo():
:
To avoid that, I need to, instead of typing ":", type the right arrow key, which is far far away in keyboard, while : is constantly under my pinky and is just easy.
How to disable this?
I have a validator function as part of a bigger program which is fifty lines long which returns True or False when you give it a string. For a certain string, it is currently returning False, and I don't which of the many return statements is firing. I can open the Python Console of the interpreter and import the function then give it its argument, but not see on which line it is returning False. Would rather not alter the main program to feed it its argument, would also rather not set breakpoints in the program for this. Is it possible in PyCharm to isolate a function, give it your own custom argument and then step through it line by line?
Am using PyCharm version 2018.2.4
Is it possible in PyCharm to isolate a function, give it your own custom argument and then step through it line by line?
No, it's not unless you create another file and write something like tests there
By clicking on left side of each line you can declare a breakpoint on the line like this:
Then you can go to debug tool window and click on the green play button
More about debuging using PyCharm
Also you can use python's breakpoint()
It is added as a built-in function in Python 3.7 but u can import it to your file on Python's 3.7-
You will see in the screenshot that pressing enter after pasting a multiline code doesnt run it but merely send each time a "...".
How can I run this multiline pasted code?
someone asked here, but did not get (the right) answer;
Did not work:
Backspace
Use the arrow key to move the cursor, then use the delete key
Escape
F2
Pressing enter twice when inside the Python interpreter executes a block of code, but you have an unmatched open parenthesis on the last line, so you haven't completed defining the block of code. Also, I'm not sure what dic is in the last line, because you haven't included its definition, so you may need to fix that as well.
Running
a=[1,2]
for x in a:
print(x)
actually works (pressing 2 enters worked as expected). So I made a mistake in the code above. I aplogise, I should have checked that before.
I don't delete the question since the one on google can be confusing (the guy did not mentioned it was his mistake, so I though there was a trick to be found. The trick is to check the code).
you could use IPython link which simplifies the process, better yet you have access to every command line as if executed inside the shell.
The other alternative is to encapsulate this inside a function
I know this answer is a bit late, but someone will need the information sometime:
When you make a new line, i.e. title.quote.... you need to press the tab to create an indent, then it will work. Without indenting, you get the "expected an indent" error message.
I'm using the cmd.Cmd library for a command line tool that I'm building and am mildly annoyed that using tab to auto-complete a command, the command line is left at the end of the command instead of appending a space to easily facilitate adding arguments.
do_function(self, line):
print(line)
and
(Cmd)func[TAB]
gives the user;
"(Cmd)function"
whereas I'd like to see;
"(Cmd)function "
with the space so I can more easily add a value to (in this case) print.
Is there any way to force an appended space after a tab completion? I assume there's an argument I can set in the cmd.Cmd class to force/allow this... but I can't find any documentation on it.
Thanks in advance.
Even when I open pure emacs -Q and a python file in it:
| - cursor
if smth:
| print("asd") # press TAB and cursor moves to "p" symbol, it's ok
if smth:
|print("asd") # press TAB and I get this:
if smth:
print("asd") # press TAB and I get prev step
So TAB makes a cyclic change of indentation level. Which I absolutely don't want to.
If to use smart-tab problem can be solved. But yasnippet (yas-global-mode 1) brings it again.
And that's where I can't find why.
If you had this problem (python+yasnippet+correct indent) - please give me a tip.
Or just a link to a working config.
Latest Emacs (24.3.50.1)
One way of controlling the cycling with TAB is to customize python-indent-trigger-commands.
The docstring of the variable states
Commands that might trigger a `python-indent-line' call.
However it is not clear from the docstring that the variable can be
used to control cycling (actually I am not even sure if setting this
variable if the correct way of controlling indentation cycling). The
docstring of python-indent-line explains the purpose of this variable better
When the variable last-command' is equal to one of the symbols
inside python-indent-trigger-commands or FORCE-TOGGLE is
non-nil it cycles levels indicated in the variable
python-indent-levels by setting the current level in the
variable `python-indent-current-level'.
So (setq python-indent-trigger-commands nil) (or you can just remove indent-for-tab-command from the list) can be used for disabling indentation cycling. There is
a slight disadvantage of this approach that you cannot use TAB indent code like the following where else
can either close for or if.
for ..:
if ..:
...
break
else:
...
You will have hit backspace before else to reindent it such that it
closes the for (by default it will be indented such that it closes the if)