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

Mark Lawrence breamoreboy at yahoo.co.uk
Sat Mar 28 08:26:43 EDT 2015


On 28/03/2015 06:26, Steven D'Aprano wrote:
> 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
>

c:\cpython\PCbuild>python
Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 24 2015, 22:44:40) [MSC v.1600 64 
bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
 >>> help(FAQ)
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
NameError: name 'FAQ' is not defined
 >>> help('FAQ')
no Python documentation found for 'FAQ'

Less than useless, now what?

-- 
My fellow Pythonistas, ask not what our language can do for you, ask
what you can do for our language.

Mark Lawrence




More information about the Python-list mailing list