[Python-ideas] Indentation, again: Problems with moving and combining code across editors.

Ron Adam ron3200 at gmail.com
Sat Aug 30 17:36:56 CEST 2014


On 08/30/2014 01:19 AM, Milind Khadilkar wrote:
> Thanks.
> The problem is mostly when code from different people using different tools
> needs to be combined, or sample code from the internet (not from the
> well-behaved ones like github and stackoverflow) has to be tested and
> understood.
> Of course it is fun to discover the lost intentions of the original
> programmer, but it is not practical in a day job.
> QUOTE
> Because we *already have it*: the character is ' '.
> UNQUOTE
> The problem with ' ' is that a sequence of ' 's can't easily be counted,
> especially on feature rich editors.
> A sequence of '.' or some visible character can be counted.
>
> Of course, with the previous line being continued on the current line, '.'
> could present problems, as Andrew B. points out, and they can be messy.
> Could the solution lie in providing a "transfer" or "import-export" mode in
> editors where the indentation is given in terms of a chosen special
> character which is converted to spaces/tabs?
> Thanks again

Unfortunately there probably isn't much you can do about uses of tabs or 
spaces outside your immediate team.  If they are all are part of your team, 
probably the best approach is to agree to set your editors to hi-light tabs 
in an obvious way, and also set them to use spaces in place of tabs.  Over 
time you should see less uses of tabs and it won't be as much of an issue.

As for cutting and pasting lines, you will still probably need to reindent 
anyway.  For that I use the indent, dedent capability of the editor if it 
has one, or a different editor that has that, if it doesn't.  It's one of 
my must have requirements.

I don't think an explicit indent character would help much, but possibly a 
relative indent marker might be useful for putting multi-line code on a 
single line.  Currently we have the ";" which only keeps the current 
indentation.  It probably wouldn't be that hard to add ";+", and ";-", 
symbols (or something equivalent), but I think it would need it's own pep 
and discussion if anyone cares enough about it.  Probably the biggest issue 
is "is it needed?", so it would need some convincing examples of how it 
would be useful.

-Ron



More information about the Python-ideas mailing list