如何从父类访问变量到子类?

时间:2018-03-27 09:50:08

标签: python

With Cte AS
(        
  select
         [groups].[name], 
         [groups].[id], 
         SUM(users.points) as points,
         Dense_Rank() Over (Partition By [groups].[id], [groups].[name] Order by SUM(users.points) Desc) as rank
  from [groups] inner join [users] on [groups].[id] = [users].[group_id] 
 )
Select [name],[id],[points] from Cte where rank<=10

我想使用&#34; s1&#34;在子类中进行一些计算并将其打印在表中 在子类中使用父类的变量的方法是什么?

1 个答案:

答案 0 :(得分:1)

首先:

Approxalumni()=父类

Reg_approx()=子类

以这种方式调用它时,从Approxalumni()继承所有函数和变量。因此,要访问s1,您只需将其分配给self:

DbLists

从那时起,您只需在父类和子类中调用self.s1作为您想要的变量。