Posts: 382
Threads: 94
Joined: Mar 2017
@ snippsat
I think nobody till now tried to copy an interactive prompt. I think this ptpython, or even python, writes somewhere all the commands you entered, since you refind them after a turn-off of the computer.
About the use of History, I tried what you discovered. It works well. But what for the piece of history you selected, and which is now at the right side ?
Posts: 382
Threads: 94
Joined: Mar 2017
Success at last. Before i paste, I had the following message: Pasting multi-line text involves sending <Enter> keypresses to console ! Continue ?
I did so and here is the result:
...
>>> class Selfless:
... ... def __init__(self, data):
... ... self.data = data
... ...
... ... def selfless(self, arg1, arg2):
... ... return arg1 + arg2
... ...
... ... def normal(self, arg1, arg2):
... ... return self.data + arg1 + arg2
...
... >>> # use Class
... >>> obj = Selfless(2)
... >>> obj.selfless(5, 8)
Posts: 7,315
Threads: 123
Joined: Sep 2016
May-31-2018, 09:51 AM
(This post was last modified: May-31-2018, 09:57 AM by snippsat.)
You need to copy the code plain code without >>> and ... ,
as i posted first.
class Selfless:
def __init__(self, data):
self.data = data
@staticmethod
def selfless(arg1, arg2):
return arg1 + arg2
def normal(self, arg1, arg2):
return self.data + arg1 + arg2 Then it look like this with code over.
You press ok 2 times about warning,then Enter 2 times.
(May-30-2018, 08:40 PM)volcano63 Wrote: Formally, you can write it the way you want - or replace with any other name, since self is just a convention. I know this,all follow the convention,so this can be info for @ sylas.
Posts: 382
Threads: 94
Joined: Mar 2017
Thanks, however, after I have copied, beside the >>> followed by the cursor(on the console) I must make a right click, which makes appear the little window, telling.......... Pasting multi-line text involves sending <Enter> keypresses to console ! Continue ?
Posts: 7,315
Threads: 123
Joined: Sep 2016
May-31-2018, 03:56 PM
(This post was last modified: May-31-2018, 03:57 PM by snippsat.)
(May-31-2018, 12:57 PM)sylas Wrote: I must make a right click, which makes appear the little window, telling.......... Pasting multi-line text involves sending <Enter> keypresses to Yes as i mention you push Ok or Enter then code will be pasted in,
then Enter and >>> show up and you can test class as show i picture.
Posts: 382
Threads: 94
Joined: Mar 2017
Since it is not obvious I think I have to speak of error handling. So I put an error in a file which ran well. Instead of print I wrote pxint.
After file was ran, interpreter noticed the error and the line.
Next I went to History (with F3). I saw the file. I went to the error line with the cursor, and then with "space" repeated many times, I had at the right pane all the lines following the error line. (error line included). Then with an ENTER the 2 Panes disappear.
Now with the cursor I go to the first line(error line) and correct the error.
Now, for running I have to go down to last line and last letter of this last line.
I run there, with just hitting ENTER.
Posts: 7,315
Threads: 123
Joined: Sep 2016
Jun-03-2018, 01:33 PM
(This post was last modified: Jun-03-2018, 01:33 PM by snippsat.)
The error will not be in History.
>>> a = 'hello'
>>> print(a)
hello
>>> prinx(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'prinx' is not defined
name 'prinx' is not defined Now F3 choose lines and Enter .
Back in normal windows Ctrl+Enter to execute.
>>> a = 'hello'
... print(a)
hello Choose(space) just line with error from history(Enter).
Ctrl+Enter to execute or just go to end on line and Enter .
The error will be regenerated bye python.
>>> prinx(a)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
NameError: name 'prinx' is not defined
name 'prinx' is not defined
Posts: 382
Threads: 94
Joined: Mar 2017
Once the correction made, no need to go to the bottom of the file, just a ctrl+enter, makes run the piece of file.
|