UserLinux chooses Python as "interpretive language" of choice

Bengt Richter bokr at oz.net
Sat Dec 20 17:39:39 EST 2003


On Sat, 20 Dec 2003 06:38:20 -0500, "John Roth" <newsgroups at jhrothjr.com> wrote:

>
>"Bengt Richter" <bokr at oz.net> wrote in message
>news:bs0amc$hsl$0 at 216.39.172.122...
>> 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
>
>I think you're missing the point I was trying to make.
Sorry, I was being superficial. BTW, the output of the above is
----
a
b
heh
Read line 2.
... which is: Beautiful is better than ugly.
----
;-)

>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
>property.
>
Nor can you supply explicit arguments if you want to, though you could
provide an alternate name, so you could access either way.
Nor can we do properties without accessing them via the attribute magic (i.e.,
not via bare global names for example).

>Ruby syntax makes it *optional*. That's what is
>missing here.
I've floated various ideas/brain_farts more/less seriously for triggering magic
via name access alterantive to getattr magic, but there seems to be no enthusiasm
or else horrification at the thought, so I haven't stirred that pot for some time ;-)

What would be the syntax you would like to use, with what effect?

Regards,
Bengt Richter




More information about the Python-list mailing list