[Tutor] hasattr()

Matthew Ngaha chigga101 at gmail.com
Sat Oct 13 20:29:45 CEST 2012

im trying to understand this hasattr function. i am supposed to pass in an
object and an attribute name into its parametres... so im trying to get it
to return True. Here's a quick test

class Test:
    def __init__(self):
       self.att = "testing"

>>> e = Test()
>>> hasattr(e, e.att)
>>> hasattr(e, "testing")

what can i do to make this True? my e object has an attribute att but it
returns False. Any code showing it return True?

the task i have been set is very difficult but i don't want to ask for help
just yet, i think understanding how hasattr works might make everything
else clear.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20121013/0f1b442f/attachment.html>

More information about the Tutor mailing list