For example:
MY_MESSAGE = 'Dear %s, hello.'
# ...
name = "jj"
print MY_MESSAGE % name
Does python have a feature for accomplishing something like my above code?
Yes, the exact way you wrote it. Your code is fine.
Python does not really have the same concept of "constant" that you will find in C. So what you have there is a fairly good approach.
I would actually argue that this is one example of "we're all consenting adults" does not hold up terribly well. Think the language is awesome, but a constant every now and again would be... nice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With