Comments on: Python http://178.63.27.54:8080/statictangents/2008/11/02/python/ Random tangents Fri, 05 Mar 2010 19:14:17 +0000 hourly 1 By: ReportLab « Stochastic Geometry http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-119 Tue, 06 Jan 2009 18:52:50 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-119 […] Filed under: General, Python, RCMS — Mark Dennehy @ 18:52 As I mentioned before, after writing a python script to read in Kada’s data files on the rifle club shooters’ […]

]]>
By: ideefixe http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-118 Fri, 07 Nov 2008 14:34:42 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-118 The layout of the Kada files is pretty consistent and straightforward – I’d be tempted to run bulk inserts with them (or even treat them as linked tables) and have them in a db rather than read in from a text file each time. That would take up even less code and be neater still. (Mind you I am thinking of this from an SQL server perspective, but I presume mySQL could work in a similar fashion

]]>
By: Top Posts « WordPress.com http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-117 Tue, 04 Nov 2008 00:04:50 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-117 […] Python One of the downsides of working on a pre-startup project is that you really can’t say much about it. Seriously. […] […]

]]>
By: Matt http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-116 Mon, 03 Nov 2008 20:32:39 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-116 Damn, that code looks ugly.

]]>
By: Python | PHP-Blog.com http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-115 Mon, 03 Nov 2008 01:57:07 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-115 […] from: Python Related ArticlesBookmarksTags There are no related articles. Digg it Stumble […]

]]>
By: tonfa http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-114 Mon, 03 Nov 2008 00:20:24 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-114 I couldn’t figure out how to use Python’s namespacing to instantiate an Image object from the Imaging library in the same script that I was using Image objects from the ReportLab library.

instead of “from foo import bar”, use “import foo.bar” or “from foo import bar as baz”.

]]>
By: Mark Dennehy http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-113 Sun, 02 Nov 2008 19:34:52 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-113 Certainly a lot more compact allright. Give me another eight to ten hours and I’ll see what I can do 😉

]]>
By: . http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-112 Sun, 02 Nov 2008 16:54:22 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-112 You should get comfortable with list comprehensions. They make code compact when you are looping and appending onto a list.

Instead of
scores = []
for s in line.split(”): scores.append(int(s))

you can do
scores = [int(score) for score in line.split()]
or even more compactly
scores = map(int, line.split())
although many woud perfer the list comp.

]]>
By: Mark Dennehy http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-111 Sun, 02 Nov 2008 13:04:29 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-111 Not according to Python Idioms and Efficiency, although looking shows that the reverse=True idiom may be newer than that…

]]>
By: George Smith http://178.63.27.54:8080/statictangents/2008/11/02/python/comment-page-1/#comment-110 Sun, 02 Nov 2008 12:58:36 +0000 http://stochasticgeometry.wordpress.com/?p=54#comment-110 keys.sort()
keys.reverse()

should be:
keys.sort(reverse=True)

]]>