Python Forum
What Does This Part of Close Alert Code Mean?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What Does This Part of Close Alert Code Mean?
#1
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.
Reply
#2
it is a placeholder.
instead of pass, you could have written:
print("NoAlertPresentException: {0}".format(e))
Reply
#3
(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!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Remove part of the code hack3rcon 5 656 Jan-08-2024, 10:25 AM
Last Post: hack3rcon
  Could you explain each part of the code? Tsushida 2 1,517 Mar-20-2022, 08:19 AM
Last Post: Larz60+
  Code to check folder and sub folders for new file and alert fioranosnake 2 1,950 Jan-06-2022, 05:03 PM
Last Post: deanhystad
  Noob Alert! Wrong result using loop and if statemnent GJG 7 2,886 Dec-19-2020, 05:18 PM
Last Post: buran
  Help with writing or plan part of code Merlin_1 1 1,816 Aug-24-2020, 03:28 AM
Last Post: Larz60+
  Explanantion needed in part of code... jayg320 6 3,517 Apr-26-2020, 11:33 AM
Last Post: anbu23
  Cant get grade part of code to work correctly Expel 5 2,682 Jul-10-2019, 05:09 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020