Python无法创建实例

2024-07-08 11:32:56 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图使用PyCXX创建一个简单的Python扩展。我正在根据python2.5安装进行编译。在

我的目标是能够在Python中执行以下操作:

import Cats

kitty = Cats.Kitty()

if type(kitty) == Cats.Kitty:
    kitty.Speak()

但每次我尝试时,我都会犯这样的错误:

TypeError: cannot create 'Kitty' instances

它确实把Cats.Kitty看作一个类型对象,但是我不能创建Kitty类的实例,有什么想法吗?在

以下是我目前的消息来源:

^{pr2}$

Tags: instancesimport类型目标iftype错误create

热门问题