Python Forum
Explanation of except ... as :
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Explanation of except ... as :
#1
Hi, i trying to figure out how the except work is...
in this python code
try:
    raise Exception("a", "b")
except Exception as e:
    print(e)
    print(e.__str__())
    print(e.args)
keyword
as e
in here mean the "e" will catch/cover the Exception class isn't it ? so does it mean the "e" variable will become an object like this ?
e = Exception("a", "b")
so how could the
print(e)
print(e.__str__())
print(e.args)
give an output
Output:
a a ('a',)
respectively....doesnt mean if we try to
print(object)
will give us an sort of output like this
Output:
<__main__.e object at 0x0000016BF4C0F880>
Reply


Messages In This Thread
Explanation of except ... as : - by Fernando_7obink - Feb-13-2021, 03:39 AM
RE: Explanation of except ... as : - by bowlofred - Feb-13-2021, 04:17 AM
RE: Explanation of except ... as : - by deanhystad - Feb-13-2021, 04:45 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Explanation of code ejKDE 4 432 Feb-26-2024, 02:50 PM
Last Post: ejKDE
  A better explanation of the last post Led_Zeppelin 9 2,438 Sep-20-2022, 05:08 PM
Last Post: deanhystad
  Operator meaning explanation Sherine 3 2,065 Jul-31-2021, 11:05 AM
Last Post: Sherine
  .maketrans() - a piece of code which needs some explanation InputOutput007 5 3,011 Jan-28-2021, 05:05 PM
Last Post: buran
  .remove() from a list - request for explanation InputOutput007 3 2,266 Jan-28-2021, 04:21 PM
Last Post: InputOutput007
  Explanation of the left side of this statement please rascalsailor 3 2,537 Sep-09-2020, 02:02 PM
Last Post: rascalsailor
  Need explanation of one line of code Fliberty 6 3,534 Feb-18-2020, 12:50 AM
Last Post: Fliberty
  explanation of code hikerguy62 2 2,270 Aug-01-2019, 01:37 PM
Last Post: hikerguy62
  While loop explanation rdgbl 1 2,314 Dec-18-2018, 01:03 AM
Last Post: stullis
  Lamda function explanation mrcool4 4 3,589 Jul-04-2018, 10:44 AM
Last Post: mrcool4

Forum Jump:

User Panel Messages

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