anti-patterns

Any reason not to use '+' to concatenate two strings?

Any reason not to use '+' to concatenate two strings? Question: A common antipattern in Python is to concatenate a sequence of strings using + in a loop. This is bad because the Python interpreter has to create a new string object for each iteration, and it ends up taking quadratic time. (Recent versions of …

Total answers: 8

Python: is using "..%(var)s.." % locals() a good practice?

Python: is using "..%(var)s.." % locals() a good practice? Question: I discovered this pattern (or anti-pattern) and I am very happy with it. I feel it is very agile: def example(): age = … name = … print “hello %(name)s you are %(age)s years old” % locals() Sometimes I use its cousin: def example2(obj): print …

Total answers: 7