PEP 285: Adding a bool type

Bengt Richter bokr at oz.net
Mon Apr 8 14:24:30 EDT 2002


On Mon, 08 Apr 2002 16:09:42 GMT, Alex Martelli <aleax at aleax.it> wrote:

>Bengt Richter wrote:
>    ... 
>>>>>Assignments in expressions will never happen.
>    ...
>> But why "identical" ;-) If I can find another spelling that works
>> everywhere (and it wouldn't surprise me if you had one in mind ;-)
>> wouldn't that be interesting?
>
>http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/66061
>
>for example.  But, like your attempt, it's based on NOT being
>an assignment (so Aahz's quote above remains perfectly right).

Well, I guess that depends on how you define "assignment" in Python.
ISTM there really is no such thing, in the sense of updating a named
storage place with new content, so what goes by the name "assignment"
needs some explanation. If the statement a=b is an assignment,
then binding the name 'a' to object b is the meaning of Python
assignment as I see it. And the expression

    locals().__setitem__('a','bee') and 0 or a

did result in binding 'a' to 'bee' in the context I used it, so
I feel justified in calling it an assignment (side effect) in an
expression ;-) I'm not sure what that side effect should be called
if not assignment, since it caused the identical binding that
a='bee' would in that context.

If it binds like a duck... ;-)

>
>Not all "stashing a reference to this value off somewhere" are
>assignments (some of the many who aren't can correctly appear
>within expressions -- others can't).
>
My criterion for judging whether it was an assignment was whether
it accomplished the same name re/binding as a normal assignment,
and I think it did, in the demonstrated context. So IMO Aahz's
quote doesn't quite remain perfectly right ;-)

Regards,
Bengt Richter



More information about the Python-list mailing list