top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Python: Convert numpy array to single number

+2 votes
585 views

I have a numpy array consisting of 1s and zeros for representing binary numbers:

e.g.

 >>> binary
 array([ 1., 0., 1., 0.])

I wish the array to be in the form 1010, so it can be manipulated. I do not want to use built in binary converters as I am trying to build my own.

posted Apr 28, 2014 by Amit Parthsarthi

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button
Is it a question, or are you just sharing?

Similar Questions
+5 votes

I am currently trying to make and use a list/array of sockets in a program. So I have declared an array as follows:

myCSocks = ['CSock1', 'CSock2', 'CSock3', 'CSock4', 'CSock5']

and I am trying to use my array elements as follows:

myCSocks[i], addr = serverSocket.accept()
 and 
message = myCSocks[i].recv(1024)

I am getting the following error:

Traceback (most recent call last):
 File "./htmlserv_multi.py", line 22, in 
 message = myCSocks[i].recv(1024)
AttributeError: 'str' object has no attribute 'recv'

This kind of makes sense to me, it is saying that my array elements are of type String and are not sockets. So I understand what my problem is but I do not know how to remedy it. I have googled "list of sockets python" but did not find anything. Any help will be greatly appreciated.

...