indentation preservation/restoration

Claudio Grondi claudio.grondi at
Tue Jan 3 10:54:28 EST 2006

smichr at wrote:
> Steven D'Aprano wrote:
>>With a little bit of work, this could be expanded to add redundancy for
>>not just indentation and numeric literals, but also string literals,
>>keywords, operators, and anything else.
> When I copy and assign to variable 'post' the reply posted here on
> c.l.p. starting with "On Mon, 02" and ending with "- \nSteven." and run
> it through the hidden() function below with the indices indicated, I
> can see what you were really thinking.
> The point is well taken: one must consider leading space as an
> important part of the code.  This is just one of those things that's so
> easy to shift around, however. You don't have to work very hard with an
> editor's text manipulations to lose it.
> That's life. I know.
> /c
> ###
> def hidden(t,indx):
>     msg=[]
>     for i in indx:
>         msg.append(t[i])
>     return ''.join(msg)
> thought=[40, 47, 51, 106, 179, 180, 181, 182, 395, 396, 399,
> 1129, 1143, 1194, 1224, 1225, 1226]
> print hidden(post,thought)
> ###

The subject of spaces in Python has been discussed over and over here in 
a manner which reminds sometimes of threads caused by simple trolling.

It is so easy to mix different things into one when not beeing able to 
see clearly what is what. Writing code is one thing, data security is 
another and compression also another thing. From the point of view of 
programming it is a origin of additional efforts required when all the 
aspects are mixed together into a data format which is to be processed. 
It would be much cleaner and easy to understand when staying separate, 
i.e. format first, than a compression scheme for it, than secure storage 
media system.

The conclusion out of it?

 From my point of view adding redundancy already at the level of source 
code is the wrong way to go and not worth to consider.
Such efforts belong to the design of a secure storage media system or 
are covered by usage of a versioning system.


More information about the Python-list mailing list