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

Eric Smith eric at trueblade.com
Sat Oct 4 11:30:41 CEST 2008


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 subclassing exceptions:
> 
> class MyTypeError(TypeError):
>     pass
> 
> * As a placeholder for code I haven't written yet.
> * As a no-op used in, e.g. the timeit module.
> 
> And probably a few other places as well.

Nick is literally (pardon the pun) saying that '...' could take the 
place of 'pass' in 3.0. His original examples are valid syntax, as 
written with the ellipses. For example:

$ ./python
Python 3.0rc1+ (py3k:66789, Oct  4 2008, 05:26:45)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-13)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
 >>> try:
...   ...
... except:
...   ...
... else:
...   ...
... finally:
...   ...
...
Ellipsis
Ellipsis
Ellipsis
 >>>

I think it's a little too cute, and 'pass' is preferable.

Eric.



More information about the Python-Dev mailing list