[Tutor] taking Python to next level (original) (raw)

Magnus Lyckå magnus at thinkware.se
Sun Jul 18 11:21:14 CEST 2004


At 22:43 2004-07-17 -0400, Brian van den Broek wrote:

Any recommendations for projects which provide good models? (I get that it would be best to read code in an application area that interests me, but I also think my request to be harder to accommodate if I pile on conditions ;-)

The obvious candidate for Python code should be Python itself. Most of the library modules are written in Python, and they have been looked at by core Python developers.

No need for any separate downloads there...

Maybe you should look at file like Tools/Scripts/reindent.py or Lib/idlelib/* etc.

Don't expect any code to be read as gospel though. The problem with the standard Python library is that a lot of the code is rather old, and doesn't take advantage of the more recent features in Python.

With any Python library, you are likely to see idioms used that might meet some controversy among developers. For instance, if I recall correctly, it's common in Twisted that methods return 'self', so that you can replace code such as:

some_object.method1(param1) some_object.method2(param2) some_object.method3(param3) some_object.method4(param4)

with

some_object.method1(param1).method2(param2).method3(param3).method4(param4)

I'm not at all sure this is good coding practice.

-- Magnus Lycka (It's really Lyckå), magnus at thinkware.se Thinkware AB, Sweden, www.thinkware.se I code Python ~ The Agile Programming Language



More information about the Tutor mailing list