- I added a module using the Setup file and the make fails; why?
- ==============================================================
- Setup must end in a newline, if there is no newline there, the build
- process fails. (Fixing this requires some ugly shell script hackery,
- and this bug is so minor that it doesn't seem worth the effort.)
- How do I debug an extension?
- ============================
- When using GDB with dynamically loaded extensions, you can't set a
- breakpoint in your extension until your extension is loaded.
- In your ".gdbinit" file (or interactively), add the command:
- br _PyImport_LoadDynamicModule
- Then, when you run GDB:
- $ gdb /local/bin/python
- gdb) run myscript.py
- gdb) continue # repeat until your extension is loaded
- gdb) finish # so that your extension is loaded
- gdb) br myfunction.c:50
- gdb) continue
- I want to compile a Python module on my Linux system, but some files are missing. Why?
- ======================================================================================
- Most packaged versions of Python don't include the
- "/usr/lib/python2.*x*/config/" directory, which contains various files
- required for compiling Python extensions.
- For Red Hat, install the python-devel RPM to get the necessary files.
- For Debian, run "apt-get install python-dev".
- How do I tell "incomplete input" from "invalid input"?
- ======================================================
- Sometimes you want to emulate the Python interactive interpreter's
- behavior, where it gives you a continuation prompt when the input is
- incomplete (e.g. you typed the start of an "if" statement or you
- didn't close your parentheses or triple string quotes), but it gives
- you a syntax error message immediately when the input is invalid.
- In Python you can use the "codeop" module, which approximates the
- parser's behavior sufficiently. IDLE uses this, for example.
- The easiest way to do it in C is to call "PyRun_InteractiveLoop()"
- (perhaps in a separate thread) and let the Python interpreter handle
- the input for you. You can also set the
- "PyOS_ReadlineFunctionPointer()" to point at your custom input
- function. See "Modules/readline.c" and "Parser/myreadline.c" for more
- hints.
- How do I find undefined g++ symbols __builtin_new or __pure_virtual?
- ====================================================================
- To dynamically load g++ extension modules, you must recompile Python,
- relink it using g++ (change LINKCC in the Python Modules Makefile),
- and link your extension module using g++ (e.g., "g++ -shared -o
- mymodule.so mymodule.o").
- Can I create an object class with some methods implemented in C and others in Python (e.g. through inheritance)?
- ================================================================================================================
- Yes, you can inherit from built-in classes such as "int", "list",
- "dict", etc.
- The Boost Python Library (BPL,
- https://www.boost.org/libs/python/doc/index.html) provides a way of
- doing this from C++ (i.e. you can inherit from an extension class
- written in C++ using the BPL).
- Cython Tutorial - Bridging between Python and C/C++ for performance gains
- https://www.youtube.com/watch?v=mXuEoqK4bEc
Python software and documentation are licensed under the PSF License Agreement.
Starting with Python 3.8.6, examples, recipes, and other code in the documentation are dual licensed under the PSF License Agreement and the Zero-Clause BSD license.
Some software incorporated into Python is under different licenses. The licenses are listed with code falling under that license. See Licenses and Acknowledgements for Incorporated Software for an incomplete list of these licenses.
Python and it's documentation is:
Copyright © 2001-2022 Python Software Foundation. All rights reserved.
Copyright © 2000 BeOpen.com. All rights reserved.
Copyright © 1995-2000 Corporation for National Research Initiatives. All rights reserved.
Copyright © 1991-1995 Stichting Mathematisch Centrum. All rights reserved.
See History and License for complete license and permissions information:
https://docs.python.org/3/license.html#psf-license