-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Class Attribute
Some koans may ask you for the __class__ attribute of an object:
What does __class__ attribute do? It tells you what the class type is for a given object (on the left hand side of the period). Let's look at that for a string object:
To the Python Console (IDLE) robin!
And run this:
"batman".__class__
!["batman".class] (http://i442.photobucket.com/albums/qq150/gregmalcolm/ScreenShot2013-05-02at75509AM.png)
Notice it returns this:
<type 'str'>
Which is the same thing we're seeing from the koans runner:
AssertionError: '-=> FILL ME IN! <=-' != <type 'str'>
So "batman" == <type 'str'> then right?
Not exactly...
!["batman" == <type 'str'>] (http://i442.photobucket.com/albums/qq150/gregmalcolm/ScreenShot2013-05-02at80309AM.png)
"batman".__class__ is DISPLAYED as <type 'str'>, but the value is actually the class name. Which is just str. NO QUOTES!

