iters on ints? (reducing the need for range/xrange)

Marcin 'Qrczak' Kowalczyk qrczak at knm.org.pl
Sat Nov 10 00:51:58 CET 2001


09 Nov 2001 15:27:26 -0800, Paul Rubin <phr-n2001d at nightsong.com> pisze:

> The trouble is as someone else noted, "for i in 10" replaces "for i in
> range(10)".  But how do you handle range(1,10)?

By writing 'range(1,10)'.

Similarly as 'for x in dict' is a shortcut for 'for x in dict.iterkeys()'
and 'for x in dict.iteritems()' must be written explicitly.

-- 
 __("<  Marcin Kowalczyk * qrczak at knm.org.pl http://qrczak.ids.net.pl/
 \__/
  ^^
QRCZAK



More information about the Python-list mailing list