Is it possible to store data in a Python file in a way similar to Ruby's __END__ section?
vthakr.safe at gmail.com
Fri Apr 2 16:08:00 EDT 2010
I have a script that I am working on to process a bunch of data. A
good portion of the Tk-based GUI is driven by a large set of YAML data
and I'd love to store that data inside of the script so that I can
send just a single file to my colleague. Ruby has a mechanism for
doing this whereby I can load the data by doing a YAML.load(DATA)
which loads everything in the file after the __END__ keyword (for a
better explanation of this see http://bit.ly/V9w8m). I was wondering
if anyone knew of a way to do something similar in Python?
I guess it's probably a good idea to point out that I am not trying to
start a flame war or compare Ruby to Python in any way, shape, or
form. I'm simply wondering if there is something in Python that is
roughly equivalent to a feature that I find useful in Ruby. If so,
I'll use it, if not, it won't make me change my mind about using
Python for my implementation, I'm quite happy with my choice, with or
without this feature.
Thanks in advance for any help you all can offer.
More information about the Python-list