On 01/03/2014 12:41 PM, Alan Gauld wrote:

         return [step, self.move_count, self.num_chutes,
self.num_ladders, self.chutes_list, self.ladders_list]

In OOP you rarely have to return attributes. And since step
is passed in as an argument the caller already knows [it]. So I
don't think you really need to return anything here.

Maybe the intent here (except from the case of step) is to conceptually isolate another part of code from the current object (here a 'game'), or from this method (play_game). So that don't they interact in a hidden way (that one cannot guess from the outside, without reading code in detail). In other words, to make code _transparent_, which is indeed a common advice (and one I approve).

In this, to have the caller explicitely, obviously read information about the 'game' object, one could just:
        return self

However, this makes no sense if the caller the cirrent method, play_game, is another method of the 'game' ;-). In this case, indeed return nothing.

(All this, if I correctly understand and interpret.)

Denis
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to