Aug-30-2019, 12:52 AM
class Test: def __init__(self): self.name = "unnamed" self.subj = "he" self.poss = "his" self.obj = "him" self.reflex = "himself" def quirks(self): return "{0.subj} is happy.".format(self) test_NPC1 = Test() print(test_NPC1.quirks())
Output:he is happy.
Process finished with exit code 0
I want to be able to run a method, like .capitalize()
, on the string value passed into the placeholder in the formatted text above, but I'm not sure how to do it. If I place it after .format(self)
, it affects the entire string, which is not what I want. I want to apply it specifically to the string value that is passed in.