Adding to a module's __dict__?
John Posner
jjposner at optimum.net
Tue Mar 2 11:18:02 EST 2010
On 3/2/2010 10:19 AM, Roy Smith wrote:
>
> Somewhat sadly, in my case, I can't even machine process the header
> file. I don't, strictly speaking, have a header file. What I have is
> a PDF which documents what's in the header file, and I'm manually re-
> typing the data out of that. Sigh.
Here's an idea, perhaps too obvious, to minimize your keystrokes:
1. Create a text file with the essential data:
XYZ_FOO 0 The foo property
XYZ_BAR 1 The bar property
XYZ_BAZ 2 reserved for future use
2. Use a Python script to convert this into the desired code:
declare('XYZ_FOO', 0, "The foo property")
declare('XYZ_BAR', 1, "The bar property")
declare('XYZ_BAZ', 2, "reserved for future use")
Note:
>>> s
'XYZ_FOO 0 The foo property'
>>> s.split(None, 2)
['XYZ_FOO', '0', 'The foo property']
HTH,
John
More information about the Python-list
mailing list