我有这门课:
class Point(PointAbstract):
"""
Class used to expand shapely.geometry.Point functionality
"""
def __unicode__(self):
return '%s, %s' % (self.x, self.y)
def __repr__(self):
return '%s, %s' % (self.x, self.y)
def __str__(self):
return '%s, %s' % (self.x, self.y)
Run Code Online (Sandbox Code Playgroud)
当我尝试通过ipdb评估实例时,我得到:
> /home/...
151 p = Point(float(each[4]), float(each[3]))
--> 152 for i, _each in enumerate(headers):
153 if not _each in headers_to_ignore:
ipdb> p
*** SyntaxError: SyntaxError('unexpected EOF while parsing', ('<string>', 0, 0, ''))
Run Code Online (Sandbox Code Playgroud)
我希望有类似的东西:
123.0, 321.0
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
p是一个pdb打印值的命令(简称print),Python期望该命令的参数.
它不被解释为名称p.使用:
ipdb> p p
Run Code Online (Sandbox Code Playgroud)
告诉p(rint)打印对象p,或者转义引用:
ipdb> !p
Run Code Online (Sandbox Code Playgroud)