top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Python: Convert numpy array to single number

+2 votes

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


 >>> 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 Google+ Share Button LinkedIn Share Button Multiple Social 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()
message = myCSocks[i].recv(1024)

I am getting the following error:

Traceback (most recent call last):
 File "./", 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.

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.