converting object ref to value????

K

Ken Godee

I'm confused, I have a class returning a value from
a method of that class and I'm getting a reference
to the object instead of the actual returned value.
How can I convert it back to an actual value I can use for
further processing?

ie.

import manager

a = manager.Manager()

xx = a.connect()

print xx

<manager.Manager object at 0x81d7034>
 
P

Peter Otten

Ken said:
I'm confused, I have a class returning a value from
a method of that class and I'm getting a reference
to the object instead of the actual returned value.
How can I convert it back to an actual value I can use for
further processing?

ie.

import manager

a = manager.Manager()

xx = a.connect()

print xx

<manager.Manager object at 0x81d7034>

Seems like the connect() method has no meaningful return value, e. g. a
manager.Connection object, so it returns self to allow you to write

a.connect().doSomething(someData)

instead of

a.connect()
a.doSomething(someData)

To be sure, you can add the test:

if xx is a:
print "connect() method returns self"

Of course, to explore what the actual methods of the Manager object instead
of the speculative doSomething() are, you have to consult the manager
module's documentation.

HTH,
Peter
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,169
Messages
2,570,915
Members
47,456
Latest member
JavierWalp

Latest Threads

Top