I'm trying to figure out if my dev environment is somehow screwed up, since "it works on [my colleagues] computer" but not mine. Instead of tackling the 'meat' of the problem, I'm working on the first funny thing I've spotted.
I have a bit of code that doesn't make sense why one call would work, and the other not:
import sys
import zmq
if __name__ == "__main__":
print sys.getdefaultencoding() # Displays 'ascii'
zContext = zmq.Context()
zSocket = zContext.socket(zmq.SUB)
# This works.
zSocket.setsockopt_string( zmq.SUBSCRIBE, "Hello".decode('ascii'))
# This fails with error... why?
# raise TypeError("unicode strings only")
#
# Shouldn't the default encoding for "Hello" be ascii?
# zSocket.setsockopt_string( zmq.SUBSCRIBE, "Hello")
zSocket.connect( "tcp://localhost:5000")
I'm assuming for the working call to setsockopt_string, that I am passing an array of ascii characters. In the broken code, I must be sending something not ascii, but not unicode. How would I know what is getting passed to setsockopt_string?
Maybe this isn't even the questions to ask. I'm just rather confused.
Any help would be great.
Here's my environment:
python --version
Python 2.7.3
#1 SMP Debian 3.2.57-3+deb7u2 x86_64 GNU/Linux
thanks.