Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Python module Inspect don't showing updated code

    General Talk
    2
    2
    608
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • mikeudinM
      mikeudin
      last edited by mikeudin

      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()
      

      Checkout my python tutorials, plugins, scripts, xpresso presets and more
      https://mikeudin.net

      1 Reply Last reply Reply Quote 0
      • r_giganteR
        r_gigante
        last edited by r_gigante

        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[URL-REMOVED]) 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


        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

        1 Reply Last reply Reply Quote 0
        • First post
          Last post