Re: [Python-Dev] if-syntax for regular for-loops

2008-10-05 Thread Nick Coghlan
Eric Smith wrote: I think it's a little too cute, and 'pass' is preferable. Agreed - it was just a little surreal to put the ... in as my usual pseudo-code stuff happens here marker, only to realise what I had written was still executable Py3k code. Cheers, Nick. -- Nick Coghlan | [EMAIL

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-05 Thread Nick Coghlan
Matthew Hawkins wrote: If there's another way of doing this I'd like to hear it. The pass statement is still the right way to denote an empty block (the compiler is already able to detect that and optimise the code appropriately). My tangential comment was based on the fact that this keyword

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-05 Thread Greg Ewing
Nick Coghlan wrote: it was just odd to notice that the Py3k interpreter would quite happily execute the example code in my postscript when I had really only intended to write it as pseudo-code with sections missing. Well, they do say that Python is executable pseudocode. :-) -- Greg

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-05 Thread Nick Coghlan
Greg Ewing wrote: Nick Coghlan wrote: it was just odd to notice that the Py3k interpreter would quite happily execute the example code in my postscript when I had really only intended to write it as pseudo-code with sections missing. Well, they do say that Python is executable pseudocode.

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-04 Thread Eric Smith
Steven D'Aprano wrote: On Sat, 4 Oct 2008 12:26:30 pm Nick Coghlan wrote: (Tangent: the above two try/except examples are perfectly legal Py3k code. Do we really need the pass statement anymore?) I can't imagine why you would think we don't need the pass statement. I often use it: * For

[Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread Andreas Nilsson
Hi. First post so here it goes. My name is Adde, and I'm a Swedish software developer. I've been programming for about 23 years now since starting with Basic on the C64. I've been through most well known and a couple of lesser known languages in search of the perfect one. At the moment I'm

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread David Gowers
Hi Andreas, On Fri, Oct 3, 2008 at 7:40 PM, Andreas Nilsson [EMAIL PROTECTED] wrote: Hi. First post so here it goes. My name is Adde, and I'm a Swedish software developer. I've been programming for about 23 years now since starting with Basic on the C64. I've been through most well known and

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread Leif Walsh
On Fri, Oct 3, 2008 at 6:10 AM, Andreas Nilsson [EMAIL PROTECTED] wrote: With that out of the way, on to todays subject: I use list comprehensions and generator expressions a lot and lately I've found myself writing a lot of code like this: for i in items if i.some_field == some_value:

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread Vitor Bosshard
- Mensaje original De: Leif Walsh [EMAIL PROTECTED] Para: Andreas Nilsson [EMAIL PROTECTED] CC: python-dev@python.org Enviado: viernes, 3 de octubre, 2008 10:29:33 Asunto: Re: [Python-Dev] if-syntax for regular for-loops On Fri, Oct 3, 2008 at 6:10 AM, Andreas Nilsson wrote:

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread Leif Walsh
On Fri, Oct 3, 2008 at 12:33 PM, Andreas Nilsson [EMAIL PROTECTED] wrote: Thanks for the pointer! I don't buy the argument that newlines automagically improves readability though. You also get increased nesting suggesting something interesting is happening where it isn't and that hurts

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread Greg Ewing
Vitor Bosshard wrote: On Fri, Oct 3, 2008 at 6:10 AM, Andreas Nilsson wrote: Essentially, all that saves is a newline or two, which, as I think has been generally accepted, tends to hurt readability. The exact same argument could be used for list comprehensions themselves. No, an LC saves

Re: [Python-Dev] if-syntax for regular for-loops

2008-10-03 Thread Nick Coghlan
Greg Ewing wrote: Vitor Bosshard wrote: The exact same argument could be used for list comprehensions themselves. No, an LC saves more than newlines -- it saves the code to set up and append to a list. This is a substantial improvement when this code would otherwise swamp the essentials of