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/2/cwd/proc/self/root/proc/2/root/usr/lib/python2.4/Demo/classes/Rev.pyo
mò
‚=5Dc@s>dZdfd„ƒYZd„ZedjoeƒndS(sð
A class which presents the reverse of a sequence without duplicating it.
From: "Steven D. Majewski" <sdm7g@elvis.med.virginia.edu>

It works on mutable or inmutable sequences.

>>> chars = list(Rev('Hello World!'))
>>> print ''.join(chars)
!dlroW olleH

The .forw is so you can use anonymous sequences in __init__, and still
keep a reference the forward sequence. )
If you give it a non-anonymous mutable sequence, the reverse sequence
will track the updated values. ( but not reassignment! - another
good reason to use anonymous values in creating the sequence to avoid
confusion. Maybe it should be change to copy input sequence to break
the connection completely ? )

>>> nnn = range(3)
>>> rnn = Rev(nnn)
>>> for n in rnn: print n
...
2
1
0
>>> for n in range(4, 6): nnn.append(n)   # update nnn
...
>>> for n in rnn: print n     # prints reversed updated values
...
5
4
2
1
0
>>> nnn = nnn[1:-1]
>>> nnn
[1, 2, 4]
>>> for n in rnn: print n     # prints reversed values of old nnn
...
5
4
2
1
0

#
>>> WH = Rev('Hello World!')
>>> print WH.forw, WH.back
Hello World! !dlroW olleH
>>> nnn = Rev(range(1, 10))
>>> print nnn.forw
[1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> print nnn.back
[9, 8, 7, 6, 5, 4, 3, 2, 1]

>>> rrr = Rev(nnn)
>>> rrr
<1, 2, 3, 4, 5, 6, 7, 8, 9>

tRevcBs,tZd„Zd„Zd„Zd„ZRS(NcCs||_||_dS(N(tseqtselftforwtback(RR((t&/usr/lib/python2.4/Demo/classes/Rev.pyt__init__?s	cCs
t|iƒS(N(tlenRR(R((Rt__len__CscCs|i|dS(Ni(RRtj(RR	((Rt__getitem__FscCs¼|i}t|tƒod}d}nMt|tƒod}d}n-t|tƒod}d}n
d}d}g}|i
D]}|t|ƒqƒ~}|d |i
|ƒ|dS(Ns[]s, s()ts<>iiÿÿÿÿ(RRRt
isinstancetlisttwraptsepttupletstrt_[1]Rtitemtoutstrstjoin(RRRRRRR((Rt__repr__Is	


*(t__name__t
__module__RRR
R(((RR>s			cCsdk}dk}|i|ƒS(N(tdoctestRttestmod(RR((Rt_testZst__main__N(t__doc__RRR(RR((Rt?<s