assignment expression peeve

Carl Banks imbosol at aerojockey.invalid
Wed Oct 15 16:26:02 EDT 2003


Paul Rubin wrote:
> Mark Day <mday at apple.com> writes:
>> If you want to address the nesting aspect of the problem, don't forget
>> the continue and break statements.  Instead of needing a (nested) else
>> clause, you can put a continue or break in the if clause, and put the
>> "else" work at the same indentation as the "if" statement itself.  
> 
> Thanks.  That's a good point and probably a workable solution for this
> situation.  However it's still a nuisance that the most natural and
> obvious way to write the code isn't permitted.

It's only natural and obvious to people who have been numbed to the
counterintuitive aspects of assignment expression by years of
programming in C.

Something that would really be the most natural and obvious way to do
it would look something like this, and you wouldn't have to put a big
turd in the language to do it:

    supposing m=re.match(s1) if m:
        do_something()
    else supposing m=re.match(s2) if m:
        do_something_else()


-- 
CARL BANKS                   http://www.aerojockey.com/software

As the newest Lady Turnpot descended into the kitchen wrapped only in
her celery-green dressing gown, her creamy bosom rising and falling
like a temperamental souffle, her tart mouth pursed in distaste, the
sous-chef whispered to the scullery boy, "I don't know what to make of
her." 
          --Laurel Fortuner, Montendre, France 
            1992 Bulwer-Lytton Fiction Contest Winner




More information about the Python-list mailing list