Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Python Institute Exam PCAP-31-03 Topic 6 Question 60 Discussion

Actual exam question for Python Institute's PCAP-31-03 exam
Question #: 60
Topic #: 6
[All PCAP-31-03 Questions]

Is it possible to safely check if a class/object has a certain attribute?

Show Suggested Answer Hide Answer
Suggested Answer: C

Contribute your Thoughts:

Junita
2 days ago
Ah, the age-old question of object attribute checking. I prefer to use a crystal ball, but hasattr() is probably more reliable.
upvoted 0 times
...
Nguyet
4 days ago
C) hassattr()? Haha, nice try, but I don't think that's a real function. Better stick to the standard hasattr().
upvoted 0 times
...
Zana
8 days ago
D) No, it's not possible? Really? That can't be right. Let me double-check the Python docs.
upvoted 0 times
...
Sueann
17 days ago
Hmm, I was sure it was B) hasattr(). Looks like I need to brush up on my Python basics.
upvoted 0 times
...
Edmond
19 days ago
A) is the correct answer. The hasattr() function is the way to safely check if an object has a certain attribute.
upvoted 0 times
...
Lindsey
20 days ago
I agree with Lewis, using hasattr ( ) method is the correct way to check for attributes
upvoted 0 times
...
Lewis
26 days ago
Yes, by using the hasattr ( ) method
upvoted 0 times
...
Nobuko
27 days ago
Is it possible to safely check if a class/object has a certain attribute?
upvoted 0 times
...

Save Cancel
az-700  pass4success  az-104  200-301  200-201  cissp  350-401  350-201  350-501  350-601  350-801  350-901  az-720  az-305  pl-300  

Warning: Cannot modify header information - headers already sent by (output started at /pass.php:70) in /pass.php on line 77