Handling 3 operands in an expression without raising an exception

Denis McMahon denismfmcmahon at gmail.com
Thu Sep 26 10:42:55 EDT 2013


On Thu, 26 Sep 2013 14:25:55 +0300, Νίκος wrote:

> Okey then please tell me, what do you see wrong in it:
> 
> socket.gethostbyaddr( os.environ.get('HTTP_CF_CONNECTING_IP')

If os.environ.get('HTTP_CF_CONNECTING_IP') is false

> or os.environ.get('REMOTE_ADDR') 

and os.environ.get('REMOTE_ADDR') is false

> or  "Άγνωστη Προέλευση" )[0]

The you try and get the host name from the ip address "Άγνωστη 
Προέλευση", but "Άγνωστη Προέλευση" is not an ip address, so you get an 
error.

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list