[Python-ideas] The "in"-statement
steve at pearwood.info
Mon Nov 5 23:36:56 CET 2012
On 06/11/12 06:28, Markus Unterwaditzer wrote:
> 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.
This is Pascal's old "with" block. It works well for static languages like
Pascal, where the compiler can tell ahead of time which names belong to what,
but less well for dynamic languages like Python. Non-trivial examples of this
design feature will be ambiguous and error-prone.
There's even a FAQ about it:
More information about the Python-ideas