Question about expression evaluation

Scott Gould zinckiwi at gmail.com
Mon Nov 8 17:17:30 CET 2010


Hi folks,

This is a head-scratcher to me. I occasionally get this error:

---
  File "/var/www/myproj/account/views.py", line 54, in account
    if request.account.is_instructor and request.account.contact and
request.account.contact.relationship.institution_party_number:

AttributeError: 'NoneType' object has no attribute 'relationship'
---

I'm leaving out all the supporting code deliberately. My question is
simple: if python short-circuits evaluation and
"request.account.contact" is None, how is it even getting as far as
"request.account.contact.relationship.institution_party_number"?

Thanks!



More information about the Python-list mailing list