Am I the only one who would love these extentions? - Python 3.0 proposals (long)

Hallvard B Furuseth (nospam nospam) h.b.furuseth at usit.uio.no
Wed Nov 12 18:19:14 CET 2003


I like some of your suggestions, like enum.  Some
particular dislikes:

Georgy Pruss wrote:

> 6) The colon is optional after for,if,try,enum etc. if it is
> followed by a new line.

Sounds to me like this would just make code harder to read, for very
little gain.  And harder to parse for editors.

> 7) Built-in regex'es. It would be nice to have built-in regular
> expressions. Probably, some RE functionality can be shared
> with the built-in string class, like presently we can write
> 'x'.encode('y'). For example $str can produce a regex object
> and then s==re can return true if s matches re. This would be
> very good for the switch construction (see below).
> E.g.
>    id = $ "[A-Za-z_][A-Za-z0-9_]*"
>    if token == id: return token

'token == id' should test if token is the same regexp, not if it
matches.  I prefer id.match(token).  OTOH, it would be an advantage if
one could write something like $"...".match(token) and have this
automatically perform re.compile, so one didn't have to put regexps one
wanted to be compiled in a variable outside the loop using them.

I don't really care much, though - beacuse I don't use python regexps
much.  I use Perl for regexpy code.  Decide for yourself if that's an
argument for or against such a change to Python:-)

> 10) Until loop -- repeat the loop body at least one time
> until the condition is true.
> 
>    until <postcond>
>       <stmts>
> 
> It's the same as:
> 
>    <stmts>
>    while not <postcond>
>        <stmts>

Very surprising semantics.  I'd expect that to be the same as:

     while not <postcond>
         <stmts>

If the while should be executed at the end, put it at the end:

    while 1:
	<stmts>
	until <postcond #1>
	<more stmts>
	until <postcond #1>

> 12) Selection statement.

Yes!

> 14) Conditional expression. Yes, I'd love it.
> 
>    cond ? yes : no

Yes!  But too late, the vote was lost.

> 16) Depreciated/obsolete items:
> -- No else for while,for,try etc -- they sound very unnatural;

Thanks for bringing this up.  I've been wishing there was a way to say
what 'try: ... except: ... else: ...' says, and I didn't know that there
already was one.

-- 
Hallvard




More information about the Python-list mailing list