In Perl, the interpreter kind of stops when it encounters a line with
__END__
in it. This is often used to embed arbitrary data at the end
With pickle you can also work directly on strings.
s = pickle.dumps(obj) pickle.loads(s)
If you combine that with """ (triple-quoted strings) you can easily store any pickled data in your file.