Favorite non-python language trick?
Sergei Organov
osv at javad.ru
Fri Jun 24 11:09:05 EDT 2005
Steven D'Aprano <steve at REMOVETHIScyber.com.au> writes:
> On Fri, 24 Jun 2005 00:55:38 -0600, Joseph Garvin wrote:
>
> > I'm curious -- what is everyone's favorite trick from a non-python
> > language? And -- why isn't it in Python?
>
> Long ago, I used to dabble in Forth. You could say, the entire Forth
> language was a trick :-) It was interesting to be able to define your own
> compiler commands, loop constructs and so forth.
>
> One of the things I liked in Pascal was the "with" keyword. You could
> write something like this:
>
> with colour do begin
> red := 0; blue := 255; green := 0;
> end;
>
> instead of:
>
> colour.red := 0; colour.blue := 255; colour.green := 0;
>
> Okay, so maybe it is more of a feature than a trick, but I miss it and it
> would be nice to have in Python.
... that quickly becomes quite messy:
with A do begin
.....
with B do begin
.....
with C do begin
x := y;
end;
end;
end;
... and now you need to check the declarations of C, B, and A to
actually see what is assigned to what.
Worse yet, adding field 'x' to 'C' will (silently) break the code :(
I don't think it would be that nice to have it in Python.
--
Sergei.
More information about the Python-list
mailing list