I would like to be able to pickle a function or class from within __main__, with the obvious problem (mentioned in other posts) that the pickled function/class is in the __m
Pickle seems to look at the main scope for definitions of classes and functions. From inside the module you're unpickling from, try this:
import myscript import __main__ __main__.myclass = myscript.myclass #unpickle anywhere after this