[Edu-sig] Python Quiz

Dethe Elza delza at livingcode.org
Wed Sep 7 20:50:44 CEST 2005


I thought this was an obscure joke on "Ghost in the Machine," but I  
didn't get it either.

--Dethe

On 7-Sep-05, at 11:35 AM, David Handy wrote:

> On Tue, Sep 06, 2005 at 03:31:36PM -0700, Kirby Urner wrote:
>
>>
>> class Shell:
>>
>>     def __init__(ghost):
>>         pass
>>
>>     def __repr__(ghost):
>>         return 'What famous Japanese cartoon?'
>>
>> OK that was easy.  So how about:
>>
>> class Shell (object):
>>
>>     def __init__(ghost):
>>         pass
>>
>>     def __repr__(ghost):
>>         return 'What famous Japanimation?'
>>
>> Hint:  think "new-style class."
>>
>> Kirby
>>
>
> I don't get it. You have two classes, both with a repr  
> implementation, and
> the second one happens to be a new-style class as indicated by its  
> being
> derived from "object". Was there more to it than that?
>
> Just in case, I copied and pasted your new-style class definition into
> kirby-ghost.py and tried it out with Python 2.3 on my machine, just  
> to see
> if there was some gotcha that I had overlooked. It works just fine  
> for me:
>
> [david at ujae stuff]$ python -i kirby-ghost.py
>
>>>> dir()
>>>>
> ['Shell', '__builtins__', '__doc__', '__file__', '__name__']
>
>>>> s = Shell()
>>>> s
>>>>
> What famous Japanimation?
>
> Loving-Python-Quizzes-but-being-puzzled-by-this-one'ly-yours,
> David H
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>


What dark passions and ancient evils have been held in check by the  
grim totalitarianism of the profit motive?  --Bruce Sterling



More information about the Edu-sig mailing list