Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #88203
| References | (1 earlier) <mailman.282.1427499534.10327.python-list@python.org> <ptrbha1f8b7rgjoo3idtflpg3fsrtmvs9t@4ax.com> <mailman.283.1427504164.10327.python-list@python.org> <9c9703b6-cfa6-4e91-900e-3a401562cb9e@googlegroups.com> <5516498e$0$13014$c3e8da3$5496439d@news.astraweb.com> |
|---|---|
| Date | 2015-03-28 17:40 +1100 |
| Subject | Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] |
| From | Chris Angelico <rosuav@gmail.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.285.1427524804.10327.python-list@python.org> (permalink) |
On Sat, Mar 28, 2015 at 5:26 PM, Steven D'Aprano <steve+comp.lang.python@pearwood.info> 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 While I don't advocate the proposal, it does have an important difference from the one cited in the FAQ - albeit a Tim-grit difference: the Pascal version has implicit attribute notation, where the proposed has a leading dot. This eliminates the ambiguity, though without majorly improving readability. ChrisA
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: Proposal for new minor syntax Ben Finney <ben+python@benfinney.id.au> - 2015-03-28 10:39 +1100
Re: Proposal for new minor syntax Mario Figueiredo <marfig@gmail.com> - 2015-03-28 01:33 +0100
Re: Proposal for new minor syntax Ian Kelly <ian.g.kelly@gmail.com> - 2015-03-27 18:55 -0600
Re: Proposal for new minor syntax Rustom Mody <rustompmody@gmail.com> - 2015-03-27 21:18 -0700
VB/Pascal with statement [was Re: Proposal for new minor syntax] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 17:26 +1100
Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] Chris Angelico <rosuav@gmail.com> - 2015-03-28 17:40 +1100
Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-28 12:26 +0000
Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2015-03-28 23:58 +1100
Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] Mark Lawrence <breamoreboy@yahoo.co.uk> - 2015-03-28 13:44 +0000
Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] Rustom Mody <rustompmody@gmail.com> - 2015-03-28 09:21 -0700
Re: VB/Pascal with statement [was Re: Proposal for new minor syntax] Rustom Mody <rustompmody@gmail.com> - 2015-03-28 09:32 -0700
Re: Proposal for new minor syntax Giorgos Tzampanakis <giorgos.tzampanakis@gmail.com> - 2015-04-08 22:11 +0000
csiph-web