Using locals() and format() method for strings: are there any caveats?
Using locals() and format() method for strings: are there any caveats? Question: Are there any disadvantages, caveats or bad practice warnings about using the following pattern? def buildString(user, name = ‘john’, age=22): userId = user.getUserId() return “Name: {name}, age: {age}, userid:{userId}”.format(**locals()) I had a very repetitive string generation code to write and was tempted to …