[Python-ideas] The "in"-statement

Markus Unterwaditzer markus at unterwaditzer.net
Mon Nov 5 20:28:41 CET 2012


This is my first post on this mailinglist and i haven't lurked a long time yet,
so please be gentle.

While mocking objects, i got annoyed by the following code pattern i had to
use when modifying multiple attributes on a single object::

    obj.first_attr = "value"
    obj.second_attr = "value2"

    some_other = "lel"

I thought it would be neat if i could do::

    in obj:
        first_attr = "value"
        second_attr = "value2"

    some_other = "lel"  # indenting this would cause it to appear as an attribute of obj

Just a vague idea. Tell me what you think.

-- Markus



More information about the Python-ideas mailing list