"Jeff Epler" <jepler at inetnebr.com> wrote in message news:slrn9emamu.cjb.jepler at potty.housenet... > On Tue, 17 Apr 2001 09:16:11 +0100, Tim Howarth > <tim at worthy.demon.co.uk> wrote: > > Being lazy, I wondered if something like the following was possible in > > Python? > > > > jim=person() > > > > Rather than typing jim each time, > > > > jim.born=1960 > > jim.haircolour='Brown' > > jim.eyecolour='Green' > > Many people have responded about this issue. > > One thing I haven't seen yet is when you need to write > a.b.c().d[4].e.f.g.h().i = 1 > a.b.c().d[4].e.f.g.h().j = 1 > a.b.c().d[4].e.f.g.h().k = 1 > that you could just as well write > temp = a.b.c().d[4].e.f.g.h() > temp.i = 1 > temp.j = 1 > temp.k = 1 > or (ugly!) > for temp in a.b.c().d[4].e.f.g.h(),: > temp.i = 1 > temp.j = 1 > temp.k = 1 > i.e., store a reference to the same thing the long expression gives you > in an easy-to-type place. > Of course, augmented assignment was made for situations where you would like to avoid writing a.b.c().d[4].e.f.g.h().k = a.b.c().d[4].e.f.g.h().k + 1 allowing you instead to write a.b.c().d[4].e.f.g.h().k += 1 I think the ugly example above is quite interesting, as it allows you to get a lot of the benefit of a "with" type of construct (these merits are, as the thread has proven, debatable), but does not add unnecessary sugar to the language syntax. regards STeve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4