I modified the test code as you suggested, but Hi2() was not created twice.

#######################
# test __getattr__() (modified as C. Anthony sugguested)
class Hi2():
    def __init__(self, name):
        *print 'in Hi2.__init__(%s)' % name*
        self.name=name
    def *call*(self):
        print 'Hi2.%s() was called'% (self.name)
class Hi(object):
    def __getattr__(self, key):
        print 'in Hi.__getattr__(%s)' % key
        return Hi2(key)
hi = Hi()
hi.there
hi.there.*call*()


result of Python:

in Hi.__getattr__(there)
in Hi2.__init__(there)
in Hi.__getattr__(there)
in Hi2.__init__(there)
Hi2.there() was called

 
result of Pyjs: 

 in Hi.__getattr__(there)
 in Hi2.__init__(there)
 
 Unknown exception: [object Error]
 Traceback:
 test_getattr.py, line 18:
    hi.there.call()

 
It is a little odd because the two sentences (hi.there and hi.there.call()) 
share the same part (hi.there) but the latter one was not called.  It looks 
like it is not just a problem of __call__() not implemented. As you can see 
I used call(), but it didn't work.

Anyway, what I want is not to use call(). I want to make my program run 
both in desktop and Pyjs without modifying my source code. I think that the 
expected behavior is how Python behaves.  The current Pyjs's behavior is 
not same to Python in the above examples, so I want to fix it.

Thanks again.

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"Pyjs.org Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to