Why using print() can get you into trouble

Sdílet
Vložit
  • čas přidán 9. 05. 2024
  • In this tutorial, I'll show you how to simplify your coding process by integrating the logging module into your Python scripts and add-ons for Blender. Discover how to effectively debug and track your script's behavior, enhancing your development workflow. Perfect for Blender developers looking to streamline their coding with better logging practices!
    Blender: How to set up Python console output on Linux
    • Blender: How to set up...
    Blender: How to set up Python console output on macOS
    • Blender: How to set up...

Komentáře • 12

  • @CGPython
    @CGPython  Před 2 měsíci +1

    📨 Subscribe, to see the extended video cg-python.ck.page/43d610dfb9
    🟠 Dr. Sybren article on logging code.blender.org/2016/05/logging-from-python-code-in-blender/

    • @RomboutVersluijs
      @RomboutVersluijs Před 10 dny

      Do you sen out the link manually, I subbed but didn't get an email. Perhaps it takes couple minutes.

    • @CGPython
      @CGPython  Před 9 dny

      @@RomboutVersluijs it should be automatic
      please let me know if you have not gotten it yet

    • @RomboutVersluijs
      @RomboutVersluijs Před 9 dny

      @@CGPython yesgot, it did took until next day. But I got the link, thanks

  •  Před 2 měsíci +1

    This is very handy and functional. Thank you for the recommendation.

    • @CGPython
      @CGPython  Před 2 měsíci +1

      You're welcome! 🙂

  • @abdullatesttest6472
    @abdullatesttest6472 Před 2 měsíci

    This is amazing! Thank you for this!

  • @SpencerMagnusson
    @SpencerMagnusson Před 2 měsíci

    Great overview on logging, thank you! I double checked my repos; there's some prints left in my add-ons that I need to upgrade 😄many are in building/zipping the add-on. Another downside to print() - it's quite slow, relative to other code statements. Removing them can speed operations up quite a bit.

    • @SpencerMagnusson
      @SpencerMagnusson Před 2 měsíci

      For the sake of discussion, I'd also add:
      - if the print() statements are for debugging, my opinion is to just remove them. Don't replace them. If it's a common issue area, there's probably something else worth fixing there. I usually don't ask for logs from customers; just a minimal .blend file and/or list of steps to cause the error.
      - if it's an error, raise it instead. Pop-up errors reported by operators are automatically logged, including the stack trace. Users will also see the error and ask for support. I hear the error message, telling me where to look in the code.

    • @CGPython
      @CGPython  Před 2 měsíci

      That is a great point!
      Thanks!

    • @CGPython
      @CGPython  Před 2 měsíci +1

      More great points!
      I think there is a difference between prints for "printf debugging" and prints for more context.
      I would agree that the prints for "printf debugging" would need to go, but there are cases where you constantly are adding that print to debug something.