While everyone is saying what they want in Python :)

David C. Ullrich ullrich at math.okstate.edu
Wed Feb 7 10:43:10 EST 2001


In article <8w_f6.13141$AH6.1969901 at newsc.telia.net>,
  "Fredrik Lundh" <fredrik at effbot.org> wrote:
> 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...)

You can do more or less the same thing in Pascal. Doesn't
have the same effect of reducing the amount of typing while
keeping things explicit, because (at least in Delphi) the
syntax would be

NewNameFortheButtonThatIInventedToSaveKeystrokes:= mybutton;
NewNameFortheButtonThatIInventedToSaveKeystrokes.caption:= 'Busy';

> Cheers /F
>
>

--
Oh, dejanews lets you add a sig - that's useful...


Sent via Deja.com
http://www.deja.com/



More information about the Python-list mailing list