Thread: Python brevity
View Single Post
Old May 21st, 2006, 9:51 AM   #1
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Python brevity

Obviously, some Python brevity is of the same type as the C/C++ ternary operator, which is to say, not really more efficient, but more efficient to write. How much do you use this in your Python? Here's an example:
    for sets in re.finditer (pattern, doc, re.I):
	medList.append ([found for found in sets.group (1, 2, 3) if found != None])
    tagList.append (medList)
The second line is an example, and all three lines could be combined. How much of this do you do? Just curious.
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote