Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python string concatenation confusion

Tags:

python

I recently came across the following piece of code. It doesn't look valid because of the single instance of triple quotes but seems to work fine. Can anyone explain what's going on here?

return ("Validation failed(%s): cannot calculate length "
        "of %s.""" % (self.name, value))`
like image 987
Jeff Terstriep Avatar asked Jun 22 '12 08:06

Jeff Terstriep


1 Answers

All of the strings are concatenated first.

"" is an empty string.

The substitutions are then made.

like image 93
jamylak Avatar answered Oct 21 '22 21:10

jamylak