MOON
Server: Apache/2.2.34 (Unix) mod_ssl/2.2.34 OpenSSL/0.9.8e-fips-rhel5 mod_bwlimited/1.4 FrontPage/5.0.2.2635
System: Linux server.asjudinet.com 2.6.32-042stab141.3 #1 SMP Fri Nov 15 22:45:34 MSK 2019 i686
User: asjudine (504)
PHP: 5.2.17
Disabled: NONE
Upload Files
File: //proc/3/root/proc/2/task/2/root/usr/lib/python2.4/Demo/classes/Range.pyo
mò
‚=5Dc@sPdZd„Zd„Zdfd„ƒYZd„ZedjoeƒndS(sExample of a generator: re-implement the built-in range function
without actually constructing the list of values.

OldStyleRange is coded in the way required to work in a 'for' loop before
iterators were introduced into the language; using __getitem__ and __len__ .

cCsñyËt|ƒdjodt|dƒdfSnšt|ƒdjo%t|dƒt|dƒdfSnbt|ƒdjo9|ddjotdƒ‚ntd„|DƒƒSntdt|ƒƒ‚Wntj
otdƒ‚nXd	S(
sgTake list of arguments and extract/create proper start, stop, and step
    values and return in a tupleiiiisstep argument must not be zeroccsx|]}t|ƒVqWdS(N(t[outmost-iterable]txtint(RR((t(/usr/lib/python2.4/Demo/classes/Range.pyt<generator expression>ss$range() accepts 1-3 arguments, givensArange() arguments must be numbers or strings representing numbersN(tlentarglistRt
ValueErrorttuplet	TypeError(R((Rt
handleargss%cgsBt|ƒ\}}}|}x ||jo|V||7}qWdS(s,Function to implement 'range' as a generatorN(R
tatstarttstoptsteptvalue(RR
RRR((Rtgenranges
toldrangecBs2tZdZd„Zd„Zd„Zd„ZRS(sClass implementing a range object.
    To the user the instances feel like immutable sequences
    (and you can't concatenate or slice them)

    Done using the old way (pre-iterators; __len__ and __getitem__) to have an
    object be used by a 'for' loop.

    cGsEt|ƒ\|_|_|_td|i|i|iƒ|_dS(s„ Initialize start, stop, and step values along with calculating the
        nubmer of values (what __len__ will return) in the rangeiN(R
RtselfRR
RtmaxR(RR((Rt__init__,scCsd|i|i|ifS(s-implement repr(x) which is also used by printsrange(%r, %r, %r)N(RRR
R(R((Rt__repr__2scCs|iS(simplement len(x)N(RR(R((Rt__len__6scCsDd|jo
|ijno|i|i|Sn
td‚dS(simplement x[i]isrange[i] index out of rangeN(tiRRRRt
IndexError(RR((Rt__getitem__:s!(t__name__t
__module__t__doc__RRRR(((RR"s
			c
Cs6dk}	dk}|idddƒ}ttdddƒƒ}ttdddƒƒ}||jp
||jot	d|||fƒ‚ndGH|	iƒ}xtdƒD]}q¬W|	iƒ}xtdƒD]}qÏW|	iƒ}x|idƒD]}qõW|	iƒ}||GdGH||GdGH||Gd	GHdS(
NiidisEerror in implementation:
correct   = %s
old-style = %s
generator = %ssTimings for range(1000):ièssec (old-style class)ssec (generator)ssec (built-in)(ttimet__builtin__trangetcorrect_resulttlistRtoldrange_resultRtgenrange_resultt	Exceptiontt1Rtt2tt3tt4(
R#RR&R(R'RR%R R"R((RttestBs.



t__main__N(RR
RRR)R(R)RRR
((Rt?s