Favorite non-python language trick?

Steven D'Aprano steve at REMOVETHIScyber.com.au
Sat Jun 25 14:08:49 EDT 2005


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.


> 2.) Contracts

Explain please.
 
> 3.) With

Explain please.


-- 
Steven.




More information about the Python-list mailing list