You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While #2 addresses the idea of leaving comments in code block as a guide to people completing the notebook, sometimes it may be desirable to have some working code retained, or a skeleton of the working code included, and not commented out. To accomplish this, it may be nice to have a way to designate lines that should be retained.
learnr accomplishes something like this with separate solution blocks, but that seems too heavyweight for this application, and potentially allows drift between the exercise block and the solution.
In the Jupyter world, nbgrader instead uses specific comments to designate the start and end of a solution section, retaining the code outside those comments, and replacing only the code within the comments with a code stub: ### BEGIN SOLUTION and ### END SOLUTION. This solution has the advantage that the solved code chunk will run in the original document as a check that it is correct behaving as intended.
Under this scheme code of the following form:
### BEGIN SOLUTION
plot(data)
### END SOLUTION
would become:
### YOUR CODE HERE
or similar.
One other alternative is an indicator that a specific line should be replaced by commenting at the end of the line that would indicate that particular line should be replaced.
This could look like this:
plot(data) ### SOLUTION
to get the same result as above.
One other implementation might include a way to strip a commented line. Something like this:
### BEGIN SOLUTION
plot(data)
#> plot(<YOURDATA>)
### END SOLUTION
could turn into:
plot(<YOURDATA>)
The text was updated successfully, but these errors were encountered:
While #2 addresses the idea of leaving comments in code block as a guide to people completing the notebook, sometimes it may be desirable to have some working code retained, or a skeleton of the working code included, and not commented out. To accomplish this, it may be nice to have a way to designate lines that should be retained.
learnr
accomplishes something like this with separate solution blocks, but that seems too heavyweight for this application, and potentially allows drift between the exercise block and the solution.In the Jupyter world,
nbgrader
instead uses specific comments to designate the start and end of a solution section, retaining the code outside those comments, and replacing only the code within the comments with a code stub:### BEGIN SOLUTION
and### END SOLUTION
. This solution has the advantage that the solved code chunk will run in the original document as a check that it is correct behaving as intended.Under this scheme code of the following form:
would become:
or similar.
One other alternative is an indicator that a specific line should be replaced by commenting at the end of the line that would indicate that particular line should be replaced.
This could look like this:
to get the same result as above.
One other implementation might include a way to strip a commented line. Something like this:
could turn into:
The text was updated successfully, but these errors were encountered: