List comprehensions: List comprehensions are pretty neat. Before studying Python I did not know what they were. This is a wonderful way to perform some operation on an entire list. Let me explain with an example. Let's say we have a list of numbers and want another list containing the double of all the numbers greater than 5 from the first list. In Java we would have to do something like this: private static List getDoubleOfMembers(List numbers) { List result = new ArrayList (); for(int num : numbers) { if(num > 5) { result.add(num*2); } } return result; } However, in Python we can perform this operation using list comprehension like this: [n*2 for n in numbers n > 5] Isn't this nice? Lambda expressions: Python supports Lambda expressions but it does not support closures like Groovy. I wish Python supported closures. Unchecked exceptions: The blogosphere has had more than it's share of discussions on checked vs. unchecked exceptions. I will not spam y...
Write Awesome User Manuals and Tutorials for Software Products