[Edu-sig] Python Pedagogy

Andre Roberge andre.roberge at gmail.com
Fri Jul 21 18:46:23 CEST 2006


On 7/21/06, Dan Crosta <dcrosta at sccs.swarthmore.edu> wrote:
> kirby urner wrote:
> > On 7/21/06, Andre Roberge <andre.roberge at gmail.com> wrote:
> >
> >> The "me" approach is very anthropomorphic and may not work well in all
> >> languages.   Mind you, the same is true for "self".
> >>
> >
> > Yes, deliberately anthropomorphic, put less about turning things into
> > people than people into things, as a skill associated with modeling
> > ("I am hydroelectric dam"  "I am an airplane" -- what are my behaviors
> > and states?).
> >
>
> What about (and this is just a random half-thought, apologies if it
> comes to nothing) using the traditional scope-ish keyword 'my' for
> increased readability?
>
> class Human:
>         def __init__(my, name):
>                 my.name = name
>
>         def __repr__(my):
>                 return 'My name is %s' % my.name
>
> Just a thought...
>

Well, while we're at it:
class Human:
    def __init__(my, name):
        my.name = name
        I = my

    def __repr__(my):
        return 'My name is %s' % my.name

    def is_hungry(I):
        print "I am hungry."
        I.eat()

    def eat(I):
        print "I eat!"

Kirby = Human("Kirby")
print Kirby
Kirby.is_hungry()
====
:-)

André


> - d
> _______________________________________________
> Edu-sig mailing list
> Edu-sig at python.org
> http://mail.python.org/mailman/listinfo/edu-sig
>


More information about the Edu-sig mailing list