UserLinux chooses Python as "interpretive language" of choice
Bengt Richter
bokr at oz.net
Fri Dec 19 21:03:56 EST 2003
On Fri, 19 Dec 2003 20:22:38 -0500, "John Roth" <newsgroups at jhrothjr.com> wrote:
>
>"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()[2]
sys.stdout = sys.__stdout__
print "Read line 2."
print '... which is:', L2
Regards,
Bengt Richter
More information about the Python-list
mailing list