0

My goal is to dynamically create many objects using setattr and then open a python prompt. Eventually I will have a object tree associated with root.

I would like to TAB after root. to see all available objects linked with root. Can anyone suggest how to do it?

import code

class Foo:
    def name(self):
        print("Checking my name")
root = Foo()
new_obj = Foo()
setattr(Foo,"new",new_obj)
code.interact(banner="", exitmsg="", local=dict(globals(), **locals()))

Example: root has dynamically created objct new which works as shown in cmd.

>>> root.new.name()
Checking my name

what I want to see after pressing TAB:

>>> root.
    new 
Dibyendu Dey
  • 349
  • 2
  • 16

0 Answers0