Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.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_Class_Inheritance_Turtle Graphics_Attributeerror - Fatal编程技术网

Python 我让类对象继承类海龟。获取属性错误

Python 我让类对象继承类海龟。获取属性错误,python,class,inheritance,turtle-graphics,attributeerror,Python,Class,Inheritance,Turtle Graphics,Attributeerror,我制作了一个单独的python文件来创建对象类。然后我将这个类导入到另一个文件,并创建了这个pad1对象 pad1 = Object("square", "blue", -350, 0) pad1.shapesize(stretch_len=1,stretch_wid=5) 但是我得到了一个错误:“Object”对象没有属性“\u outlinewidth” 对象类代码 import turtle from turtle import Turtle class Object(Turtle

我制作了一个单独的python文件来创建对象类。然后我将这个类导入到另一个文件,并创建了这个pad1对象

pad1 = Object("square", "blue", -350, 0)
pad1.shapesize(stretch_len=1,stretch_wid=5)

但是我得到了一个错误:“Object”对象没有属性“\u outlinewidth”

对象类代码

import turtle
from turtle import Turtle


class Object(Turtle):
    def __init__(self, shape, color, x, y):
        self = Turtle()
        self.speed(0)
        self.shape(shape)
        self.color(color)
        self.penup()
        self.goto(x, y)
我如何解决这个问题?我想使用单独的文件和类来解决这个问题,类似于我尝试过的方法

@rabbi76 is correct(+1),下面是对代码的修改,包括注释和一些其他问题:

from turtle import Screen, Turtle

class Pad(Turtle):
    def __init__(self, shape, color, position):
        super().__init__(shape=shape, visible=False)

        self.speed('fastest')
        self.color(color)
        self.penup()
        self.setposition(position)
        self.showturtle()

pad1 = Pad('square', 'blue', (-350, 0))
pad1.shapesize(stretch_len=1, stretch_wid=5)

screen = Screen()
screen.exitonclick()
super()。见和。