Please verify!!

Dave Angel d at davea.name
Thu Feb 23 23:43:48 CET 2012


On 02/23/2012 05:13 PM, Manish Sharma wrote:
> Hi I am new to python language. On my first day, somebody told me that
> if any python script file is opened with any editor except python
> editor, the file is corrupted. Some spacing or indentation is changed
> and script stops working. I was opening the script file in Windows
> using Notepad++ but I didn't save anything and closed it. Still it was
> suggested to never open the python file in any other editor.
>
> Can anybody please verify this? Can opening a python script in any
> editor other than python editor corrupt the script? Did anybody ever
> face such type of issue or its just misunderstanding of the concept.
>
> I hope this group is the best place to ask this. Please reply !
>
> :)
> Manish

That is nonsense.  I've used at least a dozen text editors, from Windows 
Notepad to emacs on Linux.  And since I know of no program called 
"python editor," I'm sure none of them was that one.

Of course, there are editors that are broken, or can be configured to be 
broken.  I certainly wouldn't try wordpad, even in text mode.  But a 
good editor with a good configuration can be much nicer to use than Notepad.

First thing I'd do is to disable tab logic in the editor.  When you 
press the tab key, there's no excuse for an editor to actually put a tab 
in the file.  It should adjust the column by adding the appropriate 
number of spaces.  The main place you get in trouble is when a file has 
tabs in some lines, and uses spaces for indenting on other lines.  Since 
tabs are not interpreted the same way in various utilities, it's just 
better not to use them at all.

As Amirouche has pointed out, line endings can be inconsistent between 
different operating systems, and not all editors can handle the 
differences.   But the python compiler/interpreter doesn't care about 
which line ending is used.

One other issue could be files that have non-ASCII characters.  Since a 
text file has no standard way to indicate what format it uses (utf8, 
ucs2, or dozens of "extended ASCII" encodings), another editor might not 
deal with it correctly.  There is a standard way to indicate to Python 
how to interpret non-ascii characters, so if you either  1) always use 
ASCII1 2) always use the same character encoding, or 3) have your editor 
look for the declaration and honor it,  you'd have no trouble.

If these problems do occur, they'll be pretty easy to spot.  And you can 
always revert to an earlier version, by using your revision control 
system.   Enabling one of those is about as important as choosing your 
editor.

-- 

DaveA




More information about the Python-list mailing list