我有一点我不明白的问题.
我有一个方法:
def appendMethod(self, newInstance = someObject()):
self.someList.append(newInstace)
Run Code Online (Sandbox Code Playgroud)
我称之为没有属性的方法:
object.appendMethod()
Run Code Online (Sandbox Code Playgroud)
实际上,我使用someObject的相同实例附加列表.
但是,如果我将其更改为:
def appendMethod(self):
newInstace = someObject()
self.someList.append(newInstance)
Run Code Online (Sandbox Code Playgroud)
我每次都得到该对象的新实例,有什么区别?
这是一个例子:
class someClass():
myVal = 0
class otherClass1():
someList = []
def appendList(self):
new = someClass()
self.someList.append(new)
class otherClass2():
someList = []
def appendList(self, new = someClass()):
self.someList.append(new)
newObject = otherClass1()
newObject.appendList()
newObject.appendList()
print newObject.someList[0] is newObject.someList[1]
>>>False
anotherObject = otherClass2()
anotherObject.appendList()
anotherObject.appendList()
print anotherObject.someList[0] is anotherObject.someList[1]
>>>True
Run Code Online (Sandbox Code Playgroud) 我在matplotlib中绘制一个多边形.我输入了所有坐标点.在某些点之间我想要'圆形'或'径向'边缘而不是直线(比如图中的点1和2).这可能吗?如果不是,最有效的绘制方法是什么?

编辑:Rutger的解决方案运作良好.
