Motivated from here, you can do:
[NSApp setActivationPolicy: NSApplicationActivationPolicyAccessory];
or
[NSApp setActivationPolicy: NSApplicationActivationPolicyProhibited];
This should hide the dock icon. See here for some documentation about NSApplicationActivationPolicy
.
In Python, the code to hide the dock icon is:
# http://stackoverflow.com/a/9220857/133374
import AppKit
# https://developer.apple.com/library/mac/#documentation/AppKit/Reference/NSRunningApplication_Class/Reference/Reference.html
NSApplicationActivationPolicyRegular = 0
NSApplicationActivationPolicyAccessory = 1
NSApplicationActivationPolicyProhibited = 2
AppKit.NSApp.setActivationPolicy_(NSApplicationActivationPolicyProhibited)
See also the related question "How to hide the Dock icon".
If you want to avoid that the dock icon pops up at all right at the beginning, you can do that:
import AppKit
info = AppKit.NSBundle.mainBundle().infoDictionary()
info["LSBackgroundOnly"] = "1"