-5

Sometimes developers show the stack trace with code. For example:

Traceback (most recent call last):
  File "C:/Users/Tucker Siegel/Desktop/Machines/Test.py", line 156, in <module>
    predictions = reg.predict(test)
  File "C:\Python27\lib\site-packages\sklearn\linear_model\base.py", line 200, in predict
    return self._decision_function(X)
  File "C:\Python27\lib\site-packages\sklearn\linear_model\base.py", line 183, in _decision_function
    X = check_array(X, accept_sparse=['csr', 'csc', 'coo'])
  File "C:\Python27\lib\site-packages\sklearn\utils\validation.py", line 407, in check_array
    context))
ValueError: Found array with 0 sample(s) (shape=(0, 262)) while a minimum of 1 is required.

The interpreter shows lines which are invisible in a question.

And sometimes it's handsome to have a button to copy the code fast to try it.

Dear members, do you think it can be appropriate or not?

8
  • 1
    Can you elaborate on what you mean?
    – TZHX
    Commented May 15, 2016 at 15:44
  • @TZHX Is it not clear? I mean my code without line numbers and without a button to copy it to clipboard. Oh, it's not clear, thanks.
    – sergzach
    Commented May 15, 2016 at 15:52
  • 4
    Duplicate of meta.stackoverflow.com/q/252559/2564301
    – Jongware
    Commented May 15, 2016 at 15:59
  • ..and duplicate of meta.stackoverflow.com/q/308801/2564301. The problem with asking two questions in one is that I can only close as a dup of a single one.
    – Jongware
    Commented May 15, 2016 at 16:00
  • @RadLexus smells too broad, huh?
    – Braiam
    Commented May 15, 2016 at 16:11
  • Guys, you could put selecting code JavaScript into pages. It seems not too much place for a one small button.
    – sergzach
    Commented May 15, 2016 at 16:15
  • @sergzach: the problem with line numbers, as pointed out in an answer in the linked question, is that your traceback refers to a "line 407". That means that some people are going to add all (at least) 407 lines in their code. It's one of the reasons we generally ask for a [mcve]. (Wot no hot link on MSO?)
    – Jongware
    Commented May 15, 2016 at 16:17
  • @RadLexus It's a line in the external file. To determine a current file we see to top of a stack - there is our source file. But OK, may be this idea is not so good. But what about fast code selection? Why don't make it as a button? The idea to install a custom script from APPS is strange at least. Should I install it to all my computers?
    – sergzach
    Commented May 15, 2016 at 16:20

1 Answer 1

0

One should create a MCVE when writing a question. This is usually so small that it is trivial to find the correct line, especially when OP tells us exactly what the error is, and cuts out any lines after the error that obviously were not needed to recreate the problem.

Besides this, I don't think we should make it harder to handle code on this site. If you want to copy 2 lines, you should not have to jump through hoops to do so.

Not the answer you're looking for? Browse other questions tagged .