Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!newsfeeder.ewetel.de!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.000 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'python.': 0.02; 'from:addr:yahoo.co.uk': 0.04; 'attribute': 0.07; 'error:': 0.07; 'string': 0.09; '22,': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'tismer': 0.09; 'python': 0.11; '"list': 0.16; 'addr': 0.16; 'declared': 0.16; 'googled': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'sockets': 0.16; 'subject:array': 0.16; 'elements': 0.16; 'language': 0.16; 'wrote:': 0.18; 'all,': 0.19; 'trying': 0.19; 'programming': 0.22; 'saying': 0.22; 'header:User-Agent:1': 0.23; 'second': 0.26; 'subject:/': 0.26; 'skip:" 20': 0.27; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'appreciated.': 0.29; 'array': 0.29; 'subject:list': 0.30; 'getting': 0.31; 'python"': 0.31; 'file': 0.32; 'url:python': 0.33; '(most': 0.33; 'sense': 0.34; 'problem': 0.35; 'but': 0.35; 'url:org': 0.36; 'list': 0.37; 'christian': 0.38; 'thank': 0.38; 'follows:': 0.38; 'url:library': 0.38; 'to:addr:python-list': 0.38; 'recent': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'new': 0.61; 'url:3': 0.61; 'world.': 0.61; 'you.': 0.62; 'email addr:gmail.com': 0.63; 'kind': 0.63; 'anything.': 0.68; 'received:2': 0.84 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: array/list of sockets Date: Sat, 26 Oct 2013 23:01:06 +0100 References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-2-98-201-160.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 30 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382824883 news.xs4all.nl 15870 [2001:888:2000:d::a6]:47971 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57671 On 26/10/2013 22:41, theelder777@gmail.com wrote: > Hello all, I am kind of new to python. 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'] This is a list of Python strings, not an array, not sockets. > > 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. Thank you. > See this http://docs.python.org/3/library/socket.html#example -- Python is the second best programming language in the world. But the best has yet to be invented. Christian Tismer Mark Lawrence