Coding style
Which is better? lst = [1,2,3,4,5] while lst: lst.pop() OR while len(lst) > 0: lst.pop() -- http://mail.python.org/mailman/listinfo/python-list
Re: Coding style
Bob Greschke wrote: > <[EMAIL PROTECTED]> wrote in message > news:[EMAIL PROTECTED] > > PTY wrote: > >> Which is better? > >> > >> lst = [1,2,3,4,5] > >> > >> while lst: > >> lst.pop() > >> > >> OR > >> > >> while len(lst) > 0: > >> lst.pop() > > > > A dozen posts, but nobody has posted the right > > answer yet, so I will :-) > > > > It doesn't matter -- use whichever you prefer (*) > > This is an angels on the head of a pin issue. > > > > (*) -- If your code is part of an existing body of > > code that uses one or the other style consistently, > > then you should do the same. > > > > I'd go even one step further. Turn it into English (or your favorite > non-computer language): > > 1. While list, pop. > > 2. While the length of the list is greater than 0, pop. > > Which one makes more sense? Guess which one I like. CPU cycles be damned. > :) > > Bob It looks like there are two crowds, terse and verbose. I thought terse is perl style and verbose is python style. BTW, lst = [] was not what I was interested in :-) I was asking whether it was better style to use len() or not. -- http://mail.python.org/mailman/listinfo/python-list
www.python.org
Hi, I recently browsed through your business website and wanted to highlight some key points for consideration. I am sure it will complement your-SEO work to help your website attract only quality visitors and make it scale high on the search .engine results page (SERP) gradually. Would you be interested in receiving the details? Best regards, Eileen Online-Strategist CELLsIX MEDIA PTY LTD. Headquarters: Office 7003 X2 Tower, Cluster X, Melbourne Vic. 3000 Australia Other Branches: Sydney | Perth | Brisbane | Adelaide | Hobart Disclaimer: This e-mail is private and confidential. If you are not the intended recipient, please advise us by return e-mail immediately, and delete the e-mail and any attachments without using or disclosing the contents in any way. The views expressed in this e-mail are those of the author, and do not represent those of this company unless this is clearly indicated. You should scan this e-mail and any attachments for viruses. This company accepts no liability for any direct or indirect damage or loss resulting from the use of any attachments to this e-mail. All quotes received from Cellsix Media by email are informal and not binding until a formal quote is agreed upon by both the parties. -- https://mail.python.org/mailman/listinfo/python-list
