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?