Python Forum
What Does This Part of Close Alert Code Mean? - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: What Does This Part of Close Alert Code Mean? (/thread-8276.html)



What Does This Part of Close Alert Code Mean? - digitalmatic7 - Feb-12-2018

Hey guys,

Here's the code snippet:

try:
    driver.switch_to.alert.dismiss()
except NoAlertPresentException as e:
    pass
I understand what it does for the most-part.. try to switch to and dismiss popup, otherwise handle the exception and keep it moving.. what confuses me is specifically the "as e" part...

In this situation I'm not sure what it does.


RE: What Does This Part of Close Alert Code Mean? - Larz60+ - Feb-13-2018

it is a placeholder.
instead of pass, you could have written:
print("NoAlertPresentException: {0}".format(e))



RE: What Does This Part of Close Alert Code Mean? - digitalmatic7 - Feb-13-2018

(Feb-13-2018, 12:53 AM)Larz60+ Wrote: it is a placeholder.
instead of pass, you could have written:
print("NoAlertPresentException: {0}".format(e))

That makes sense... it's naming it to call it later.

I think I need to spend a few hours to learn how Python syntax works. I can mash together snippets of code really well, but I have problems editing and understanding certain sections.

Thanks again for the helpful explanation, cheers!