Python

Py logo

 

 

Been on Python for a few months.  After the initial bump (10 yrs of Java, mandatory indents, peppering of `self` all over OO) I rather like it now. It’s pretty easy to write clean, almost DSL like code.

okToDisplay = lambda book: book.Type not in ('Inventory', 'Customer') and not isTest(book)
groupPosBy  = {'Tranche': positionsForBookByTranche}[groupBy]
return [groupPosBy(book) for book in books if okToDisplay(book)]

lambda (anonymous functions) and compact iteration (list comprehension) are very handy. The map (dictionary) of functions patters virtually eliminates the need for switch. We don’t have a single switch in our whole app !
Don’t even bother thinking how much code that would be in Java 😉

Advertisements
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s