No 1.6! (was Re: A REALLY COOL PYTHON FEATURE:)

Dan Schmidt dfan at harmonixmusic.com
Fri May 19 09:34:51 EDT 2000


m.faassen at vet.uu.nl (Martijn Faassen) writes:

| Glyph Lefkowitz <glyph at twistedmatrix.com> wrote:
| > m.faassen at vet.uu.nl (Martijn Faassen) writes:
| 
| >>   I sit on the chair
| >         .
| >>   chair.sit() 
| 
| > Hmm.  This is not the way I think of it.  I would never say
| > chair.sit() ... more like, 
| 
| > "Bob, sit on the chair."
| 
| > bob.sit(chair)
| 
| > After all, who's doing the work here; bob, or the chair?
| 
| Depends on how you're modelling. In many muds for instance, the 
| world objects determine what's possible with them, not the players.
| The player issues some commands and the player object knows just
| enough to be able to pipe it to the world objects (which then can
| query the player. So more like:
| 
|   chair.sit(bob)
| 
| Though that does look a bit odd. :)
|  
|   chair.be_sat_on_by(bob)

I'd probably say

  chair.accept_sitter(bob)

As with Glyph and Martijn's examples, I always try to phrase the names
of my methods so that they sound like commands to be given to the
object, at least the ones that don't return values.  I find that the
flow of the 'text' works best this way.

-- 
Dan Schmidt | http://www.dfan.org



More information about the Python-list mailing list