Python module Inspect don't showing updated code



  • Hello, guys!
    I've been trying to find solution to get python function code and inspect module seems to be working nicely but only in python shell and Subline Text console. But when i try to launch this code on Cinema 4D Scripts Manager it shows me only first version code and after changing script code keeps showing same results. It's like a there is uncleaned cache...🤔
    Any ideas how to fix this thing? Thx!

    import inspect
    # Save this code as script py-file and start
    
    def main():
    
      code = inspect.getsource(main_new) # place function code to str variable
      print code # print code text. Works on Python Shell, but not in C4D Scripts Manager
    
    def main_new():
      # This is a comment
      # New comment string 
      # Change this code, to check the console output
      pass
    
    
    if __name__ == '__main__':
      main()
    


  • Hi @mikeudin, thanks for reaching out us.

    With regard to your request, although it's not expected it to work inside the Cinema 4D Script Manager you can get it properly working using the c4dpy executable (here's the 20.059 compatible version) as much as you do on the Python Shell or on SublimeText console as you can see from the log below.

    $ more test.py
    import inspect
    # Save this code as script py-file and start
    
    def main():
    
      code = inspect.getsource(main_new) # place function code to str variable
      print code # print code text. Works on Python Shell, but not in C4D Scripts Manager
    
    def main_new():
      # This is a comment
      # New comment string 
      # Change this code, to check the console output
      pass
    
    
    if __name__ == '__main__':
      main()
    
    
    $ ./c4dpy.app/Contents/MacOS/c4dpy test.py 
    def main_new():
      # This is a comment
      # New comment string 
      # Change this code, to check the console output
      pass
    
    $
    

    Best, Riccardo