pre-PEP for optional 'pass'

jepler at unpythonic.net jepler at unpythonic.net
Mon Apr 15 23:29:05 EDT 2002


On Tue, Apr 16, 2002 at 12:26:10AM +0100, phil hunt wrote:
> 
> OK, I've decided to write a PEP. Preliminary to this, I'd like 
> people's comments.
> 
> I wish to make the pas startement optional. That is, in any Python 
> program where there is a pass it can be left out and the meaning of 
> the program is unchanged.

Actually, I'd rather have the 'yada-yada-yada' operator, which I believe is
also slated for inclusion in Perl6.  It's spelled '...' and is placed in the
'atom' production in the grammar:
    atom: ... | NAME | NUMBER | STRING+ | '...'

If the "..." part of an expression is ever reached during normal
evaluation, a NotImplemented exception is raised.

Thus, if you would write
    class MyPrototype:
	def __init__(self, x, y, z): ...

Attempting to create an instance of MyPrototype would raise
NotImplemented.  Also, if you have a complicated expression that you've only
partly finished, such as
    def xor(a,b): return (a or b) and not (a and ...)
this will raise NotImplemented when a is true, since the author hasn't
finished.

The new syntax
    [1, 2, 3, ...]
would create a generator that gives successive positive integer values.  
    [2, 3, 5, 7, 9, ...]
would generate successive primes.  However, if Python cannot guess what
series the leading items define, then it will raise NotImplemented when
the 'yada' term is reached.  Two examples of this might be
    ['99 bottles of beer on the wall', '99 bottles of beer', 
	    'take one down', ...]
    ['spam', 'spam', 'spam', 'spam', 'spam', ...]
though of course Python reserves the right to recognize new patterns in
bugfix releases.

Jeff
PS Hey, it's still April! 





More information about the Python-list mailing list