KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
If I try the following code (in Python 3.2.2), def f(): raise Exception x = f() then it appears that x is untouched - it either remains undefined or keeps whatever value it had previously. Is this behaviour guaranteed whenever the right hand side of an assignment throws an exception? I realise this is a very basic question, but I can't find much information about how exactly assignment works. More generally, is the entire right hand side always evaluated before anything relating to the assignment happens? Is this even true when using setattr , assigning to an element of a list, or using tuple unpacking (i.e. something like x, y = y, f() )?
Tags (comma-separated)
Save Edits
Cancel