[Python-ideas] The "in"-statement

alex23 wuwei23 at gmail.com
Tue Nov 6 04:53:44 CET 2012

On Nov 6, 5:39 am, Markus Unterwaditzer <mar... at unterwaditzer.net>
> I thought it would be neat if i could do::
>     in obj:
>         first_attr = "value"
>         second_attr = "value2"

My concern is that it would promote its own code flow at the expense
of readability. It's great for simple assignment, but doesn't allow
for anything else:

    in obj:
        first_attr = function1()
        temp_var_not_an_attr = function2(first_attr)
        second_attr = function2(temp_var_not_an_attr)

And what is the expected behaviour for something like:

    first_attr = "FOO"
    in obj:
        first_attr = "BAR"
        second_attr = first_attr

Is obj.second_attr "FOO" or "BAR"?  How do I distinguish between outer
& inner scope labels?

More information about the Python-ideas mailing list