Prev: Getting Local MAC Address
Next: Is it possible to store data in a Python file in a way similar to Ruby's __END__ section?
From: Martin v. Loewis on 2 Apr 2010 16:44 Christopher Roach wrote: > 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? The common approach is to write DATA="""\ yaml data here """ If you want to process the data in the same file, you can't really put them at the end of the file - in fact, putting them at the beginning is more common. Regards, Martin |