Re: Rev() with better repr [and complaint about pedantic typechecking]

Steven D. Majewski (sdm7g@galen.med.virginia.edu)
Thu, 28 Oct 1993 17:40:32 -0400

I wrote ( re: difference in string.joinfields vs. strop.joinfields )
>
> Not in string.py (as far as I can tell). It must be from the internal
> strop version. Is there any way to import the joinfields from
> string.py over the one in strop module ? ( Or is the solution
> to fix strop's joinfields ? )
>

I didn't actually mean that question the way it was phrased.
[ Well - yes, I *DID* mean it at the time, but I wasn't thinking! :-) ]
There's a clear way HOW to import string.joinfields
rather than strop.joinfields: either edit the "try: from strop import *"
line out of strings.py, or copy join & joinfields in another file
( join.py ).

What I really meant was:
(1) does anyone else besides me really CARE that they don't work
identically?
(2) and is the "correct & standard" fix to distinguish the two
more clearly ( a "generic" join and a _s_t_r_i_n_g_.join[fields],
or to make strop.join[fields] work like string.join[fields] ?

It wouldn't work generically for what I wanted to do with repr,
since I didn't want to join the values but the repr's of the values.

But it WOULD be nice if string and sequence functions worked for
pseudo-strings and pseudo-sequence object classes. For example -
if I actually wrote a mutable string class, I would expect
string.split to work on it. ( strop.split won't. )

Finally:
Maybe a better repr for Rev is:
Rev( repr( Rev( seq ).forw ) )
i.e. just the reverse of the string-representation of the sequence:

>>> Rev( repr( Rev( [1,2,3] ).forw ) )
]3 ,2 ,1[
>>> Rev( repr( Rev( (1,2,3) ).forw ) )
)3 ,2 ,1(
>>> Rev( repr( Rev( '123' ).forw ) )
'321'
>>>

Looks a little strange, but it indicates, for tuples and lists,
that they really *aren't* tuples or lists.

- Steve Majewski