Στις 27/9/2013 3:17 μμ, ο/η Dave Angel έγραψε:
On 27/9/2013 07:15, Νίκος wrote:

Στις 27/9/2013 1:43 μμ, ο/η Dave Angel έγραψε:

    <snip>

ipval = ( os.environ.get('HTTP_CF_CONNECTING_IP') or
os.environ.get('REMOTE_ADDR', "Cannot Resolve") )
city = "Άγνωστη Πόλη"
host = "Άγνωστη Προέλευση"
try:
        city = gi.time_zone_by_addr( ipval )
        host = socket.gethostbyaddr( ipval ) [0]
except socket.gaierror as e:
        pass

Thanks for taking the time to expain this:

In the exact above solution of yours opposed to the top of mines is that

No idea what you mean here.  I'll assume you're talking about the
version you DON'T quote here, the one with the if statements in the
except clause.

you code has the benefit of actually identifying the variable that
failed to have been assigned a value while in my code no matter what
variable failes in the try block i assign string to both 'city' and
'host' hence i dont really know which one of them is failing?

Yes, it has that advantage. Of course it doesn't USE that advantage for
anything so I'd go back to the pass version quoted immediately above.
Or I'd have two separate try/except clauses, one for each function call.
  After all, the implication of the failure is different for each.



Di i understood it correctly?

I think so.


Thank you for everything, i appreciate your time and effort to help me understand.
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to