NodePath.ls() doesn't return anything

Hello, I am trying to use the NodePath.ls() function, but it simply does not print anything. No errors either. What am I doing wrong? Here is an image of the console where I typed the function.
image
As you can see, app.scene has 69 children.
I hope you can help me. Thank you!

Are you sure that you call this on the node? Try on the render.ls()

I am not sure exactly what I am doing, but I tried to follow the manual. Trying it on render doesn’t work either.
image
Any ideas?

There are no ideas since you did not provide the code.

from direct.showbase.ShowBase import ShowBase

class MyApp(ShowBase):

    def __init__(self):
        ShowBase.__init__(self)

        self.model = self.loader.loadModel("box")
        self.model.reparentTo(render)
        print(render.ls())

app = MyApp()
app.run()
PandaNode render S:(CullFaceAttrib RescaleNormalAttrib)
  ModelNode camera
    Camera cam ( PerspectiveLens )
      PerspectiveLens fov = 50.942 30
  ModelRoot box.egg
    GeomNode box (1 geoms: S:(TextureAttrib))
None

Here is the code: https://pastebin.com/tpnsCfpS
It is pretty awful, I know, I just use it for learning the engine.

As you can see, I added print(render.ls()) in the __init__ function, where I executed it from the console before, but it still returned None. I also tried changing render to self.scene as that is what I reparent most objects to. Still no ouput. I also tried adding the line in the load_scene function, as that is where I reparent all the objects. Still no output.

I find it really weird. Perhaps I should try with one of the sample projects instead.

Edit: I just tried to add print(render.ls()) in the end of __init__ function of the glow-filter sample project. I am still getting None as output.

Does the code I provided work for you? Just check it out.
I suspect a problem with your terminal, maybe it just displays one last line. Take a look at the panda console.

Hello!
What is your version of Panda3D?

The “ls()” method doesn’t return a string to be printed–it prints the results itself, I believe.

That is, the “print”-statement is superfluous–just calling “render.ls()” (or “someOtherNodePath.ls()”) should be enough.

(Although, while this explains the “print”-statement writing out “None”, I’m not sure of why “ls()” isn’t printing anything despite the “print”-statement–it should, I believe.)

What happens if you just print “app.scene”? That is, if you run “print (app.scene)”?

I am 100% sure that the problem is with the IDE. It displays only one line.

PandaNode render S:(CullFaceAttrib RescaleNormalAttrib)
  ModelNode camera
    Camera cam ( PerspectiveLens )
      PerspectiveLens fov = 50.942 30
  ModelRoot box.egg
    GeomNode box (1 geoms: S:(TextureAttrib))
None

This - ^

As @Thaumaturge points out, render.ls() always returns None, after printing the list to the notify output (which I think is stderr by default).

If you want to capture the result in a string, you should pass a StringStream as the argument to ls().

Does your IDE perhaps capture stderr, only printing stdout? Or did you set up Panda to capture notify-output?

I am using Panda3D 1.10.4.1 64bit version.

I use IDLE and tried running your example, still no output. However, when executing the script with the command prompt, I got the output. Is there any way that I could make IDLE print the output?
Thanks for your help :slight_smile:

I use IDLE and as @serega-kkz mentioned, it seems to be an issue with the IDE. I did change anything in the Panda3D settings.

I tried to both print the function and just call the function. It seems, that is doesn’t matter what node I am trying, still no output. However, as @serega-kkz mentioned, it seems to be an issue with the IDE. I am using IDLE and as far as I know, I have not changed any of its printing settings.

May try.
from pprint import pprint
pprint (data)

That did not seem to work either. Perhaps I should just run the game from the command prompt whenever I want to print the node graph. Thanks for your help anyway :slight_smile: