Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.164 X-Spam-Level: * X-Spam-Evidence: '*H*': 0.69; '*S*': 0.02; '[0]': 0.09; 'subject:error': 0.09; 'name)': 0.16; 'wrote:': 0.18; 'header:In- Reply-To:1': 0.22; 'code': 0.25; '(and': 0.28; 'received:199': 0.29; 'pm,': 0.29; 'host': 0.30; 'usually': 0.31; 'does': 0.32; 'list': 0.32; 'header:User-Agent:1': 0.33; 'to:addr:python-list': 0.34; 'explain': 0.36; 'skip:\xce 10': 0.38; 'skip:o 20': 0.38; 'being': 0.39; 'why': 0.39; 'to:addr:python.org': 0.40; 'address': 0.61; 'forum': 0.64; '8bit%:100': 0.69; 'subject:( ': 0.84; 'canonical': 0.91; 'subject:skip:s 20': 0.91 X-IronPort-AV: E=McAfee;i="5400,1158,6584"; a="151244873" Date: Mon, 09 Jan 2012 14:35:42 -0800 From: Dominic Binks User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error References: <24123dfe-b2fc-4f4c-8dfe-23bfef19b205@m10g2000vbc.googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 15 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1326148616 news.xs4all.nl 6853 [2001:888:2000:d::a6]:39870 X-Complaints-To: abuse@xs4all.nl Xref: x330-a1.tempe.blueboxinc.net comp.lang.python:18713 On 1/9/2012 2:19 PM, Νικόλαος Κούρας wrote: > Can you please explain me what the [0] in host = > socket.gethostbyaddr( os.environ['REMOTE_ADDR'] )[0] does at the end? > > Why not just host = socket.gethostbyaddr( os.environ['REMOTE_ADDR'] ) > instead? what is the need of [0] ? The address database can have multiple names for the same IP address so gethostbyaddr returns a list - [0] being the first item in the list (and usually considered the canonical name) -- Dominic Binks: dbinks@codeaurora.org Employee of Qualcomm Innovation Center, Inc. Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum