Writing Python macros requires extra configuration steps to set an IDE of choice.
Unlike Basic language macros development in LibreOffice, developing Python scripts for LibreOffice requires to configure an external Integrated Development Environment (IDE). Multiple IDEs are available that range from beginners to advanced Python coders. While using a Python IDE programmers benefit from numerous features such as syntax highlighting, code folding, class browsing, code completion, coding standard enforcement, test driven development, debugging, version control and many more. You can refer to Designing & Developing Python Applications on the Wiki for more in-depth information about the setup of a bridge between your IDE and a running instance LibreOffice.
The Alternative Python Script Organizer (APSO) extension eases the edition of Python scripts, in particular when embedded in a document. Using APSO you can configure your preferred source code editor, start the integrated Python shell and debug Python scripts. Extensions exist that help inspect arbitrary UNO objects, refer to Designing & Developing Python Applications for additional details on such extensions.