On 10/12/06, Kevin Horn <[EMAIL PROTECTED]> wrote: > - Use list comprehensions and "for item in list" structures as much as > possible
Actually, this is debatable. You definitely should use comprehensions instead of map() and friends, as it makes a bit more sense to people without a functional programming background, but sometimes a normal for loop is clearer. I have a problem with this because I love list comprehensions and tend to shoehorn too much into my comprehensions. I'll add: - Dictionaries are very fast in Python and tend to be used a lot more than hash tables are in Java/C++. Unless the collection needs to be ordered (and sometimes even when it does) I tend to dump it in a dict. - Use the 'in' keyword - It's better to beg forgiveness than ask permission. Try to just do whatever you wanted to do with the object and catch the error if it was raised. People do all sorts of crazy things with the built in types, so you'll get complaints if someone's custom list-behaving dict doesn't work with your list processing code. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "TurboGears" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/turbogears -~----------~----~----~----~------~----~------~--~---

