Very weird behavior that's driving me crazy

Pupeno pupeno at pupeno.com
Wed Aug 16 04:01:26 EDT 2006


Nevermind, it was fixed. Thanks.

Pupeno wrote:

> Hello,
> I am experiencing a weird behavior that is driving me crazy. I have module
> called Sensors containing, among other things:
> 
> class Manager:
>     def getStatus(self):
>         print "getStatus(self=%s)" % self
>         return {"a": "b", "c": "d"}
> 
> and then I have another module called SensorSingleton that emulates the
> hard-to-code-on-python singleton in this way:
> 
> manager = Manager()
> print "manager=%s" % manager
> def getStatus():
>     print "getStatus()"
>     return manager.getStatus()
> 
> and then in some other module, I import SensorSingleton and I do, among
> other things:
> 
>     print SensorSingleton.getStatus()
> 
> and the output is more or less like this. First, the manager:
> 
> manager: <Sensor.Manager object at 0xb7b9efec>
> 
> ok, then
> 
> Manager.getStatus(self=<Sensor.Manager object at 0xb77cde8c>) =>
> {"a": "b", "c": "d"}
> None
> 
> None is the return of SensorSingleton.getStatus(), now, my questions are:
> 
> - Shouldn't the manager be the same in the first print and the second,
> that is, the id is different, shouldn't it be the same ?
> - What happened with all the output of SensorSingleton.getStatus() ?
> there's no trace of it (but there's output of the method it calls).
> - Why doesn't the SensorSingleton.getStatus() return the return value of
> manager.getStatus(), it's a very straight forward call to it and return
> it.
> 
> Thank you.

-- 
Pupeno <pupeno at pupeno.com> (http://pupeno.com)



More information about the Python-list mailing list