[Python-3000] Test and Assign [was: More wishful thinking]

Talin talin at acm.org
Sun Apr 16 23:59:24 CEST 2006


 <skip <at> pobox.com> writes:

> This really isn't Python 3000 material, folks.  I thought my first response
> would trigger an "Oh yeah, I hadn't thought of that", not continual
> ill-conceived "yeah, but you can do this instead when the situation is
> right".  Please take it c.l.py, hash it out there, and if a reasonable idea
> floats to the top of the soup, raise it on python-dev unless the idea is
> somehow backward-incompatible and has to wait until Python 3000.

It's also gotten off track. You're right, the discussion of the implementation
details of re.match isn't Python-3000 material, but that's not what I
was really talking about.

I'm really more interested in the general case where you have a test, and
then you have the results of the test. It would be nice to put the conditional
statement first, and then once you know that the test succeeded, start to
look at the specific details.

Its like coming home and finding someone has left you a birthday present,
so you decide to open it and see what's inside, as opposed to coming home,
attempting to see what's in the birthday present, and then noticing that
there isn't one.

Now I agree, that this isn't a huge issue, I only bring it up because it occurs
so frequently. The number of lines of code isn't affected - the only thing
that would be affected is the readability of the code IMHO. I'm happy to
drop the subject if that's what folks want ::)

(One of the things I've been doing is going through my codebase looking
for coding patterns that are awkward attempts to get around language
limitations.)

PS. I meant to change the title of that last post as well - could whoever
replies to the "More Wishful Thinking" topic please change the title of
their next posting as well? Thanks :)

-- Talin




More information about the Python-3000 mailing list