VB/Pascal with statement [was Re: Proposal for new minor syntax]

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sat Mar 28 02:26:21 EDT 2015


On Sat, 28 Mar 2015 03:18 pm, Rustom Mody wrote:

> One thing that is a bit laborious in python are object initializers:
> 
> self.attr1 = field1
> self.attr2 = field2
> 
> In VB one can do:
> 
> with self
> .attr1 = field1
> .attr2 = field2
> 
> (or something like that -- dont exactly remember the syntax)


Pascal is another language with a construct like that, and there's a FAQ for
it:

https://docs.python.org/2/faq/design.html#why-doesn-t-python-have-a-with-statement-for-attribute-assignments



-- 
Steven




More information about the Python-list mailing list