Why not allow empty code blocks?

Chris Angelico rosuav at gmail.com
Sun Jul 24 10:51:02 EDT 2016


On Mon, Jul 25, 2016 at 12:44 AM, BartC <bc at freeuk.com> wrote:
> Your attention is diverted, you're doing something on your desk, but you hit
> one of the keys by mistake. You might have pressed Delete or you might not.
> You look at the screen which has a 5000-line program open, and you see this
> (borrowing your example and with the cursor at "_"):
>
>  def f():
>      for x in seq:
>          do_this()
>          do_that()
>  _   do_more()
>
> Did you just unindent do_more(), or is that where it's meant to be? Undo may
> or may not help (or it may undo something is needed).

Undo, redo. See what happened. Easy.

Also, if you're regularly committing to source control, you can always
check the diff. Before you 'git commit', check what 'gitk' shows, or
before 'hg commit', have a glance at 'hg diff'. Make sure what you're
seeing is what you intend to change. Remember, code doesn't just
accidentally change; everything should have purpose, including
(especially) any indent/unindent.

Source control protects you from everything other than multiple
changes since the last commit. So commit often. It'll save you a lot
of time - if not coding time, then debating-on-python-list time. :)

ChrisA



More information about the Python-list mailing list