I've got this strange problem, I created an instance called structure, I made a function which return an object of this type. Just before returning, I print it, it gives me the right object. Now when I collect it in 'main' and print it, it becomes 'None'. If someone can give me advice, it will be very appreciated.


Show me or it's not true.

It is not really easy but this is the function

def locate(K,p):
         locate the point p in the structure S
         root = K.child
         print root
         if root == {}:
                   The point is located
                   print K
                   return K
                   The point is in the child of root
                   print 'Here'
                   for i in range(len(root)):
                              if InSide(root[i].node,p):
                                       print DT.triangle(root[i].node)

It's a point location in a tree formed by subdivision of triangle. May be the recurssion is not really good. Now this is the result

{0: <__main__.structure instance at 0x8468d2c>, 1: <__main__.structure instance at 0x8468d4c>, 2: <__main__.structure instance at 0x8468d6c>}
<__main__.structure instance at 0x8468d6c>

The None is the printing in main


The problem is in the else, you are doing recursion yes? You don't want to simply call locate, but you want to return what it returns. So change locate(root[i],p) to return locate(root[i],p) Cheers.