Favorite non-python language trick?

James fphsml at gmail.com
Sun Jul 3 01:48:20 EDT 2005


Steven D'Aprano wrote:
> On Fri, 24 Jun 2005 14:29:37 -0700, James wrote:
>
> > Interesting thread ...
> >
> > 1.) Language support for ranges as in Ada/Pascal/Ruby
> > 1..10 rather than range(1, 10)
>
> What advantages do Pascal-like for loops give over Python for loops?
>
> The only two I can think of are trivial:
>
> (1) the Pascal-like for loop is six characters shorter to type:
>
> for i = 1 to 10:        # 16 chars
> for i in range(1, 10):  # 22 chars
>
> (2) for very large ranges, you don't have to hold the entire list of
> integers in memory. But you can use xrange() instead of range(), which
> also doesn't hold the entire list in memory.

First, I was never concerned about what I can do with the new keyword
that I could not do without since most languages are turing complete.
The question is that of elegance and it is subjective. I do know that
if Python kept adding features that everyone liked, it will end up like
Perl (although D seems to be doing a great job incorporating everyone's
favorite features while still retaining language consistancy. Then
again, it is very new.). But this thread is about favorite features
from other languages.

Secondly, the point was about ranges. Their use in loops (as in Ada and
Ruby) is just one instance. For me, they are more readable in the same
way I like -- for comments as in Eiffel and Ada rather than // and #
which do the same.


> > 2.) Contracts
>
> Explain please.

Design By Contract (as in Eiffel and D)

> > 3.) With
>
> Explain please.

As in Delphi
http://www.delphibasics.co.uk/RTL.asp?Name=With

There have been some PEPs regarding this.




More information about the Python-list mailing list