On Mon, 9 May 2016 12:25 am, DFS wrote: >>> for j in range(len(nms)): >>> cSQL = "INSERT INTO ADDRESSES VALUES (?,?,?,?,?)" >>> vals = nms[j],street[j],city[j],state[j],zipcd[j]
Why are you assigning cSQL to the same string over and over again? Sure, assignments are cheap, but they're not infinitely cheap. They still have a cost. Instead of paying that cost once, you pay it over and over again, which adds up. Worse, it is misleading. I had to read that code snippet three or four times before I realised that cSQL was exactly the same each time. > I tried: > > for nm,street,city,state,zipcd in zip(nms,street,city,state,zipcd): > > but felt it was too long and wordy. It's long and wordy because you're doing something long and wordy. It is *inherently* long and wordy to process five things, whether you write it as: for i in range(len(names)): name = names[i] street = streets[i] city = cities[i] state = states[i] zipcode = zipcodes[i] process(...) or as: for name, street, city, state, zipcode in zip( names, streets, cities, states, zipcodes ): process(...) > I like the first one better. python is awesome, but too many options > for doing the same thing also makes it difficult. For me, anyway. That's the difference between a master and an apprentice. The apprentice likes to follow fixed steps the same way each time. The master craftsman knows her tools backwards, and can choose the right tool for the job, and when the choice of tool really doesn't matter and you can use whatever happens to be the closest to hand. -- Steven -- https://mail.python.org/mailman/listinfo/python-list