Ruby Impressions

Phil Tomson ptkwt at shell1.aracnet.com
Fri Jan 11 03:43:18 EST 2002


In article <23891c90.0201100347.19c0a672 at posting.google.com>,
Paul Boddie <paul at boddie.net> wrote:
>gandy at techie.com (Thomas Gandy) wrote in message
>news:<752891fc.0201091327.5842485f at posting.google.com>...
>>
>
>[Ruby compared to Python]
>
>>                   As I'm glancing through code I (and it's my opinion)
>> must say it's easier to see the '@''s than the 'self's (and there's a
>> bit less typing to do).
>
>[...]
>
>> In Python we do:
>> 
>> class SomeClass:
>>    def __init__(self,value):
>>       self.data = value
>> 
>> In Ruby you do:
>> 
>> class SomeClass
>>    def initialize(value)
>>       @data = value
>>    end
>> end
>
>Although I would probably get used to it eventually, the use of
>"initialize" rather than "__init__" seems to demand more effort (if
>not really any more typing), especially for those of us who don't have
>US English as our first language. ;-)

Well, in Ruby if you want to you can always open up class Class and 
redefine new to call __init__ instead of initialize - now it may not be a 
real good idea to redefine new, but you can if you really want to ;-)

Phil




More information about the Python-list mailing list