Yes, of course you can. Write the program rpg.py.m4 , preprocess it with m4 (link)
into rpg.py , then run your program with python. I've found that technique especially useful with bison
programs in which the source code can be quite repetitive. And, since bison is a mix of c fragments with grammar rules, you can't just apply cpp
macros. Often it happens that the "big chunk of code" depends on something. Say, perhaps, the values of some local variables. m4 allows for this---the macros take arguments that are duly substituted, possibly recursively.
The clever designers of python considered that you might have a "big chunk of code" destined for reuse. They realized the difficulty of reading a clumsy program with repeated "big chunk of code". And, having made the mistake once or twice themselves, considered the well being of future programmers who would have to maintain the mess when, for whatever reason, the code changes. And so they included functions, classes, and methods to alleviate the problem. Methods are functions belonging to an object with easy access to relevant data.
You yourself have used functions, guiding the action with information you supplied! Don't believe this? AHAH! Look here.
print("You swing your fist to hit [" + str(damage) +"] damage.")
But how, you ask, can I create my own reusable chunk of code? How can I make my own function??? READ HERE
, then continue your study with classes, methods, and attributes.