Striving for PEP-8 compliance

Gabriel Genellina gagsl-py2 at yahoo.com.ar
Wed Apr 7 17:58:43 CEST 2010


En Wed, 07 Apr 2010 11:53:58 -0300, Tom Evans <tevans.uk at googlemail.com>  
escribió:

> [ Please keep me cc'ed, I'm not subscribed ]

Sorry; you may read this at  
http://groups.google.com/group/comp.lang.python/

> I've written a bunch of internal libraries for my company, and they
> all use two space indents, and I'd like to be more consistent and
> conform to PEP-8 as much as I can.

reindent.py (in the Tools directory of your Python installation) does  
exactly that.

> My problem is I would like to be certain that any changes do not alter
> the logic of the libraries. When doing this in C, I would simply
> compile each module to an object file, calculate the MD5 of the object
> file, then make the whitespace changes, recompile the object file and
> compare the checksums. If the checksums match, then the files are
> equivalent.

If you only reindent the code (without adding/removing lines) then you can  
compare the compiled .pyc files (excluding the first 8 bytes that contain  
a magic number and the source file timestamp). Remember that code objects  
contain line number information.

-- 
Gabriel Genellina




More information about the Python-list mailing list