Compare source code

Steven D'Aprano steve at REMOVE-THIS-cybersource.com.au
Sat Nov 6 03:13:59 CET 2010


On Fri, 05 Nov 2010 18:45:39 +0000, Seebs wrote:

> On 2010-11-05, Steven D'Aprano <steve at REMOVE-THIS-cybersource.com.au>
> wrote:
>> On Thu, 04 Nov 2010 20:17:35 +0000, Seebs wrote:
>>> That was the thing which bit me the worst.  I had a fairly large block
>>> of code in a first-pass ugly program.  I wanted to start refactoring
>>> it, so I moved a big hunk of code into a method (with plans to further
>>> refactor).  It took about fifteen minutes to redo the logic.
> 
>> Well there's your problem -- you are relying on tools that operate by
>> magic.
> 
> Wrong.

Really? Then how did the logic get screwed up from a mere copy-and-paste 
operation?

In context (which you deleted), you were agreeing with Mark Wooding who 
wrote:

"I /do/ have a significant problem with cutting and pasting code in 
Python.  In most languages, I can haul a chunk of code about, hit C-M-q, 
and Emacs magically indents the result properly.  This is, unfortunately, 
impossible with Python.  It has caused me real bugs, and I have to be 
extra careful to fix the indentation up."

[Aside: he isn't having problems with cutting and pasting code in Python, 
but in Emacs.]

You *agreed with him*, and related your story. In context, I think it was 
perfectly reasonable to conclude that you too used C-M-q in Emacs, which 
then "magically indents the result". Mark's words, not mine.

But perhaps you were using Notepad, and you just hit Ctrl-V, and 
something else mangled the code so badly you needed to spend 15 minutes 
re-creating the program logic. I am open to correction either way.


>> Rather than re-create the logic, why not just hit Undo and then
>> re-paste the code *without* the magic auto-reformat? Half a second, to
>> undo and re- paste, followed by 10 or 20 seconds to select the
>> appropriate lines and *explicitly* re-indent the lines to the correct
>> level.
> 
> There was no magic auto-reformat.  Where did you invent that from?  Why
> are you making stuff up which I never said or referred to?

Then how did the logic get mangled from a simple copy and paste operation?

What god-awful editor are you using that can't copy and paste text 
without mangling it?



-- 
Steven



More information about the Python-list mailing list