Use python's implicit string concatenation and implicit line concatenation inside unterminated brackets/parenthesis...:
MS = ('M-SEARCH * '
'HTTP/1.1\r\n'
'HOST: %s:%d\r\n'
'MAN: "ssdp:discover"\r\n'
'MX: 2\r\n'
'ST: ssdp:all\r\n\r\n') % (SSDP_ADDR, SSDP_PORT)
Note that some (including Guido) seem to dislike implicit string concatenation. If you fall into that category, you can use explicit concatenation (just add a +
's where necessary). There's no real harm in doing this -- the bytecode optimizer will optimize the concatenation away just the same as it does with implicit concatenation.