UserLinux chooses Python as "interpretive language" of choice
newsgroups at jhrothjr.com
Sat Dec 20 12:38:20 CET 2003
"Bengt Richter" <bokr at oz.net> wrote in message
news:bs0amc$hsl$0 at 188.8.131.52...
> On Fri, 19 Dec 2003 20:22:38 -0500, "John Roth" <newsgroups at jhrothjr.com>
> >"Steve Lamb" <grey at despair.dmiyu.org> wrote in message
> >news:slrnbu77jp.nh8.grey at dmiyu.org...
> >> On 2003-12-20, John Roth <newsgroups at jhrothjr.com> wrote:
> >> > a third is the ability to forget the empty parenthesis after
> >> > a function/method call that doesn't require parameters.
> >> class ThisIs:
> >> avariable = 'a'
> >> def amethod(self):
> >> return 'b'
> >> thisis = ThisIs()
> >> print thisis.avariable
> >> print thisis.amethod()
> >> import this
> >> print "Read line 2."
> >I'm not sure what your point is. Your example isn't going
> >to produce the expected result if you say:
> >print thisis.amethod
> >instead of
> >print thisis.amethod()
> >That is the place where I find Ruby syntax to be
> >helpful: the amount of time where I want the method /
> >function object is *far* lower than the amount of
> >time I want to call it. It's one of those conundrums
> >that doesn't seem to have a clean answer, though.
> Ok, for line 2, run this ;-)
> class ThisIs:
> avariable = 'a'
> def amethod(self):
> return 'b'
> def silly(self):
> return 'heh'
> silly = property(silly)
> thisis = ThisIs()
> print thisis.avariable
> print thisis.amethod()
> print thisis.silly
> import sys
> class L2(list):
> def write(self, s): self.append(s)
> sys.stdout = L2()
> import this
> L2 = ''.join(sys.stdout).splitlines()
> sys.stdout = sys.__stdout__
> print "Read line 2."
> print '... which is:', L2
> Bengt Richter
I think you're missing the point I was trying to make.
Sure, you can use a property to not have to put
in the explicit function call, but then you can't put
in the explicit function call *anywhere* you use that
Ruby syntax makes it *optional*. That's what is
More information about the Python-list