Στις 27/9/2013 12:26 μμ, ο/η Steven D'Aprano έγραψε:
On Fri, 27 Sep 2013 12:19:53 +0300, Νίκος wrote:

I'am not sure what you mean though when you say:

Simply assign the default values BEFORE the try block, and use pass as
the except block.

Can you please make it more clear for me?


variable = "default value"
try:
     variable = something_that_might_fail()
except SomeException:
     pass

Thanks Steven but this way i still have to declare the default string sfor the variables:

Its no different than:

except socket.gaierror as e:
        city = "Άγνωστη Πόλη"
        host = "Άγνωστη Προέλευση"

Your way set the vars on top, the other way set the vars inside the except block.

--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to