2
$\begingroup$

I like to include short, one-off python scripts with a post now and then. Sometimes the script is central to the post so I include it as a code block within the post the same way it's done in other SE sites and SO.

However sometimes this is to supplement the text and equations as an additional way to explain something or to support the method. An example just now is this answer, another is What is Tiangong-2 doing?. I've used pastebin.com a few times for this, selecting "keep forever".

Is that the best way, or are there other options, and if so, what might their relative merits be?

$\endgroup$
2
$\begingroup$

I guess the ideal (and most professional) way would to do it would be to share your code as repository (on GitHub, BitBucket or GitLab, for example) in case it has several files, or in Gist, in case is just a snippet.

The main advantages is that, in both cases, people can fork and clone, and thus modify, your code and use it as they want. Furthermore, in the case of GitHub, people can add Jupyter Notebooks, for example, and their code "exploration" will show up in a nicely formatted way.

$\endgroup$
  • $\begingroup$ If you've seen my "incidental scripts" they are usually just 20 to 100 lines of python script; run once and forget. I'm hesitant to post those kinds of things in GitHub, do people really use it that way? Pastebin allows me to just copy and paste it there. With GitHub if I don't start adding supporting files (at least a README) then I feel bad. $\endgroup$ – uhoh Sep 20 '18 at 16:56
  • 1
    $\begingroup$ @uhoh For what it's worth, I use GitHub for this: github.com/called2voyage/just-so-snippets. I mean, it's empty right now, so I guess technically I will use it for this. $\endgroup$ – called2voyage Sep 20 '18 at 17:37
  • 1
    $\begingroup$ @uhoh Gist works exactly like that, it's ideal for very small pieces of code. The front page is literally a text box to paste your script! $\endgroup$ – user17622 Sep 20 '18 at 18:07
  • $\begingroup$ Thanks, I've looked at these further and decided that moving to one of these is probably just fine! $\endgroup$ – uhoh Oct 3 '18 at 17:50

You must log in to answer this question.

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