pythonstringtextgrowlnotify

Python remove spaces and append


I am currently writing a growl notification plugin for emesene messenger on OS X. It is nearly working except to when it comes to displaying a message snippet.

The message is passed to growlnotify as a variable, however growl does not accept spaces in the displayed message.

So what i need help with is a script to remove the spaces between multiple words and replace it with a \ then a space.

e.g. Original: This is a message What is needed: This\ is\ a\ message

I have looked around at similar answers but i could not work out how to append the slash.


Solution

  • Instead of trying to do this with os.system(), use subprocess instead, passing the program and arguments as a list.