About reading Python code
jeff at schwabcenter.com
Tue Mar 18 02:29:17 CET 2008
> On 17 Mar, 04:54, WaterWalk <toolmas... at 163.com> wrote:
>> So I'm curious how to read code effectively. I agree that python code
>> is clear, but when it becomes long, reading it can still be a hard
> First, I recommend that you write readable code! Don't use Python as
> if you're entering the obfuscated C contest.
Er, don't use anything other than C if you're entering an obfuscated C
contest, or anything other Perl for an obfuscated Perl contest, etc.
Do use Python if you're entering an obfuscated Python contest. Found
[#[#[#[#[#[#[#[#[# By TaroOgawa #]#]#]#]#]#]#]#]#]
lambda x: globals()
];print ( " ".join(
> Two particularly important points:
> * If you find yourself thinking this module is too long, that's
> probably what it is. Half a page of code per module is fine. Two pages
> of code per module can be too much.
> * Comments are always helpful to the reader.
If only 'twere so. *Good* comments are always helpful. Please do not
comment every method with "this is a method" or the like. One of the
things that often makes newb code stand out is that the programmer
couldn't tell the things that needed to be commented from the places
where comments just got in the way.
> Second, I recommend getting a good IDE. E.g. pick one of:
> * Microsoft Visual Studio (commercial)
> * Eclipse with PyDev and CDT (free)
> * SPE (free)
> * ActiveState Komodo IDE (commercial)
* Vim on Linux. (No desire here to debate the meaning of IDE, but with
Vim or Emacs on any Unix-like platform, the whole system effectively is
More information about the Python-list