Στις 29/9/2013 2:04 πμ, ο/η Chris Angelico έγραψε:
On Sun, Sep 29, 2013 at 4:45 AM, Mark Lawrence <breamore...@yahoo.co.uk> wrote:
Not tortured, simply murdered so we don't have to put up with his completely
unacceptable behaviour, which sadly is thriving owing to so many people
ignoring the "do not feed this moron" signs.
You miss one important factor in these discussions: the silent
majority of readers. We have a few people here who are not "worth"
responding to, as they're highly unlikely to listen (the most
noteworthy other example being jmf on Unicode), but that doesn't mean
the threads can't be useful to someone else. And sometimes there can
be some extremely entertaining conversation, too.
That's also why I don't plonk anyone :)
Its not that i don't listen, its that i want something to be implemented
in a specific way.
ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
try:
gi = pygeoip.GeoIP('/usr/local/share/GeoIPCity.dat')
city = gi.time_zone_by_addr( ipval )
host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
My question was if the above code, in the except clause, can be written
in 1-line while identifying which one of the two variables have failed
to be assigned a value in the try: clause and assign to it respectively.
And i don't mean like this:
if not city:
city ="blabla"
if not host:
host="blablabla"
Can thes be witten without and if perhaps with the use of 'or' operator
in 1-line within the except clause?
--
https://mail.python.org/mailman/listinfo/python-list