Python Quiz

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Python Quiz

Kirby Urner

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



_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Python Quiz

David Handy
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@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
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Python Quiz

Dethe Elza
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@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
> [hidden email]
> 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

_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Python Quiz

Grégoire Dooms
In reply to this post by Kirby Urner
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."
>
>  
>
Is it that new-style classes are to old-style classes what animation is
to old-style cartoons ?
--
Grégoire


PS: this mailing list is really deviating from "Python in/for education".


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig
Reply | Threaded
Open this post in threaded view
|

Re: Python Quiz

Kirby Urner
In reply to this post by Kirby Urner

Answers:

Ghost in the Shell:
http://www.imdb.com/title/tt0113568/

Ghost in the Shell 2: Innocence
http://www.imdb.com/title/tt0347246/

(new-style as in sequel, next generation, or freshmeat)

Kirby


> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]] On
> Behalf Of Kirby Urner
> Sent: Tuesday, September 06, 2005 3:32 PM
> To: [hidden email]
> Subject: [Edu-sig] Python Quiz
>
>
> 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
>
>
>
> _______________________________________________
> Edu-sig mailing list
> [hidden email]
> http://mail.python.org/mailman/listinfo/edu-sig


_______________________________________________
Edu-sig mailing list
[hidden email]
http://mail.python.org/mailman/listinfo/edu-sig