Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
创建一个可拾取的Python类_Python_Python 2.7_Python 3.x_Class_Debugging - Fatal编程技术网

创建一个可拾取的Python类

创建一个可拾取的Python类,python,python-2.7,python-3.x,class,debugging,Python,Python 2.7,Python 3.x,Class,Debugging,我正在尝试为我的应用程序创建一些自定义Python类。当我试图调试代码时,我无法选择自定义类的实例,我收到错误“objectxxx不可选择”。 我找到了这个页面,但我不明白应该如何实现使我的类可拾取的方法。 例如,您将如何修改以下类,以便我可以选择它们的实例 class Point3D: def __init__ (self, x, y, z): self.x = x self.y = y self.z = z def move(self, vector):

我正在尝试为我的应用程序创建一些自定义Python类。当我试图调试代码时,我无法选择自定义类的实例,我收到错误“objectxxx不可选择”。 我找到了这个页面,但我不明白应该如何实现使我的类可拾取的方法。 例如,您将如何修改以下类,以便我可以选择它们的实例

class Point3D:
  def __init__ (self, x, y, z):
    self.x = x
    self.y = y
    self.z = z

  def move(self, vector):
    self.x += vector.x
    self.y += vector.y
    self.z += vector.z
    return

  def isValidPoint(self):
    isNotValid = False
    isNotValid = math.isnan(self.x) or math.isnan(self.y) or math.isnan(self.z)
    return not isNotValid

在这里,您可以找到我试图调试的代码:

from classDatabase import Point3D, PointCloud3D

testPoint1 = Point3D(1.5, 0.2, 2.3)
testPoint2 = Point3D(3.5, 1.2, 5.3)

testPointCloud3D = PointCloud3D()
testPointCloud3D.addPoint(testPoint1)
testPointCloud3D.addPoint(testPoint2)
最后是问题的屏幕截图:

修复缩进“可拾取”,而不是“可拾取”。这些类的实例是可拾取的。显示正在出错的代码添加代码和快照。谢谢嗯,我可以在Python 3.5.2中执行pickle.dumps(textPointCloud3D)。你确定没有其他事情发生吗?修复缩进“可拾取”,而不是“可拾取”。这些类的实例是可拾取的。显示正在出错的代码添加代码和快照。谢谢嗯,我可以在Python 3.5.2中执行pickle.dumps(textPointCloud3D)。你确定没有其他事情发生吗?
from classDatabase import Point3D, PointCloud3D

testPoint1 = Point3D(1.5, 0.2, 2.3)
testPoint2 = Point3D(3.5, 1.2, 5.3)

testPointCloud3D = PointCloud3D()
testPointCloud3D.addPoint(testPoint1)
testPointCloud3D.addPoint(testPoint2)