socket.gethostbyaddr( os.environ['REMOTE_ADDR'] error

Νικόλαος Κούρας nikos.kouras at gmail.com
Mon Jan 9 18:04:12 EST 2012


On 10 Ιαν, 00:35, Dominic Binks <dbi... at codeaurora.org> wrote:
> 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)

Thank you!



More information about the Python-list mailing list