python - 在安装的pygame目录中哪里可以找到pygame.init()方法?

标签 python pygame

我找不到 pygame.init() 函数。请看看我做了什么。

ckim@chan-ubuntu:~$ python
Python 2.7.12 (default, Nov 12 2018, 14:36:49) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import pygame
pygame 1.9.4
Hello from the pygame community. https://www.pygame.org/contribute.html
>>> print (pygame.__file__)
/usr/local/lib/python2.7/dist-packages/pygame/__init__.pyc
>>> pygame.init()
(6, 0)

所以我在/usr/local/lib/python2.7/dist-packages/pygame 下搜索但找不到模块 pygame 的 init() 源代码。在那里我找到了包含 init 的 base.so 文件(使用 nm base.so 检查)。那么pygame是不是安装了所有的源代码,一些用C或C++实现并由.so文件提供的函数和类型?

最佳答案

是的,pygame 的很大一部分是用 C 语言编写的。

Here's pygame模块的init方法的来源。

我不知道在 Linux 中编译的文件是什么样的,因为我目前没有准备好 pygame 的 Linux 机器。但是在 Windows 上,你会发现例如base.cp37-win32.pyd,它基本上是一个包含已编译 C 代码的 DLL。

关于python - 在安装的pygame目录中哪里可以找到pygame.init()方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55611686/

相关文章:

python - 我应该如何附加到 mongodb 中的小文件状对象?

python - 我可以在调用函数之前对函数参数/变量进行猴子修补吗?

python - 在pygame中渲染消失的文本

python - 如何使用 Pygame 裁剪图像?

c++ - 如何以向后方式遍历python和c++中的文件?并且还以向后(从下到上)的方式存储数据?

python - 使用二变量样条与 scipy.ndimage.geometric_transform 来配准图像

python - 折叠列并插入新行?

python - 在pygame中实现曲线上的碰撞检测

python - 将对象 move 一定数量的像素? - Python/Pygame

python - 如何使用 pygame 将整个像素数组放在屏幕上?