On 6/4/2014 7:23 PM, Mark H Harris wrote:
On 6/4/14 5:18 PM, Terry Reedy wrote:
On 6/4/2014 10:53 AM, Mark H Harris wrote:
The primary paradigm on this topic locally is that
indents are bad because malformed or mangled code cannot be reformatted
easily (if at all).
Begin solution:':' as the end of a line means 'begin block; indent next
line'. If one is using tools that mangle, one can add end-of-block
comments: '# end, # end if, # if (end implied), or even just ##. In any
case, the stylized comment could mean 'dedent' and code could be
reconstituted with all indents stripped. There are probably programs on
PyPI to do that. End of excuse.
Yup. Well, I've only been doing python coding for ~9-10 years, but
I've never had this formatting problem.
The only problem I have seen is when people post code here with \t for
indent. Many mail readers treat \t as a null char since it actually has
no standard translation into screen space. This is one reason why PEP8
recommends using spaces rather than \t for indent. On today's systems,
the space saved with \t is not worth the trouble.
> I viewed the entire debate as
'an excuse'. I'm going to do some looking on PyPI-- it would be nice to
point folks to something concrete. If its an excuse, then that puts an
end to it.
As long as I'm addressing an IDLE guy, what would you think of a
feature for IDLE that would format python code with block delimiters
automatically and visa versa ?
I would not include it by default, as I would not want to encourage
block-commenting Python code. However, anyone could write an extension
that would add 3 menu items: BlockIn (add block comment), BlockDent
(re-indent according to block markers), and BlockOut (remove block
comments). The editor Format menu would be the obvious place. One would
not have to parse; instead let tokenize do that. Then BlockIn: add Block
comment and Newline tokens before Dedent tokens; BlockDent: replace
BlockComment Newline with Dedent. In either case, follow with
untokenize. Simply removing block markers could be done directly. The
block comment could even be user configurable.
(At the moment, untokenize does not properly reconstitue files indented
with \t.)
--
Terry Jan Reedy
--
https://mail.python.org/mailman/listinfo/python-list