2 Break wall of text with a simple paragraph marker :)
source | link

Sometimes, your programming language just doesn't have the facilities you want, making it actually impossible to write functions or macros to do what you want. Or maybe you could do what you want, but the code to write it would be ugly. A simple Python script (or similar) can then generate the required code as part of your build process, which you then #include into the actual source file. 

How do I know this? Because it's a solution I've reached for multiple times when working with various different systems, most recently SourcePawn. A simple Python script that parses a simple line of source code and produces two or three lines of generated code is far better than manually crafting the generated code, when you end up with two dozen such lines (creating all my cvars).

Demonstrative/example source code available if people want it.

Sometimes, your programming language just doesn't have the facilities you want, making it actually impossible to write functions or macros to do what you want. Or maybe you could do what you want, but the code to write it would be ugly. A simple Python script (or similar) can then generate the required code as part of your build process, which you then #include into the actual source file. How do I know this? Because it's a solution I've reached for multiple times when working with various different systems, most recently SourcePawn. A simple Python script that parses a simple line of source code and produces two or three lines of generated code is far better than manually crafting the generated code, when you end up with two dozen such lines (creating all my cvars).

Demonstrative/example source code available if people want it.

Sometimes, your programming language just doesn't have the facilities you want, making it actually impossible to write functions or macros to do what you want. Or maybe you could do what you want, but the code to write it would be ugly. A simple Python script (or similar) can then generate the required code as part of your build process, which you then #include into the actual source file. 

How do I know this? Because it's a solution I've reached for multiple times when working with various different systems, most recently SourcePawn. A simple Python script that parses a simple line of source code and produces two or three lines of generated code is far better than manually crafting the generated code, when you end up with two dozen such lines (creating all my cvars).

Demonstrative/example source code available if people want it.

1
source | link

Sometimes, your programming language just doesn't have the facilities you want, making it actually impossible to write functions or macros to do what you want. Or maybe you could do what you want, but the code to write it would be ugly. A simple Python script (or similar) can then generate the required code as part of your build process, which you then #include into the actual source file. How do I know this? Because it's a solution I've reached for multiple times when working with various different systems, most recently SourcePawn. A simple Python script that parses a simple line of source code and produces two or three lines of generated code is far better than manually crafting the generated code, when you end up with two dozen such lines (creating all my cvars).

Demonstrative/example source code available if people want it.