What's better about Ruby than Python?

Michele Simionato mis6 at pitt.edu
Mon Aug 18 18:01:38 EDT 2003


"John Roth" <newsgroups at jhrothjr.com> wrote in message 
news:<vk1c89jvdjepa4 at news.supernews.com>...
> 3. Not having to write "self" in the method definition. This falls out of
> item 2: since every function/method has an instance, there's no need to
> declare it. I've thought of writing a PEP for this one.

Out of curiosity: how does Ruby manages inner classes like this?

class MyClass(object):
    def __init__(self,x):
        class InnerClass(object):
            def __init__(innerself,a):
                innerself.a=a 
		self.b=2*a
        self.x=InnerClass(x)

c=MyClass(1)

print c.x.a # =>1
print c.b # =>2

an-ex-enemy-of-self-now-converted-ly-your's

                     Michele




More information about the Python-list mailing list