While everyone is saying what they want in Python :)

Fredrik Lundh fredrik at effbot.org
Tue Feb 6 23:02:44 CET 2001


Daniel Kinnaer wrote:
> The part where I find the 'with' command interesting is for
> readability.  Consider :
>
> MySpecialButton := TSpecialButton;
> MySpecialButton.caption := 'Busy';
> MySpecialButton.method2;
> MySpecialButton.caption := "Ok";
>
> or
>
> MySpecialButton := TSpecialButton;
> with MySpecialButton do
> begin
>    caption := 'Busy';
>    method2;
>    caption := 'Done';
> end;
>
> Which code would you prefer?

b = mybutton = TSpecialButton()
b.caption = "Busy"
b.method2()
b.caption = "Ok"

(variables are just names in Python -- you can have any
number of names pointing to the same thing...)

Cheers /F





More information about the Python-list mailing list