覆盖一个属性 [英] override a property

查看:82
本文介绍了覆盖一个属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法覆盖实例中的数据属性?我是否需要创建

另一个类改变了属性?

-

Robin Becker

Is there a way to override a data property in the instance? Do I need to create
another class with the property changed?
--
Robin Becker

推荐答案

不,你可以随时做。您甚至可以动态创建属性

(属性)。


class Dummy:

property = True


d = Dummy()

d.property = False

d.new = True


Stani

-

SPE - Stani的Python编辑器 http://pythonide.stani.be

No, you can just do it on the fly. You can even create properties
(attributes) on the fly.

class Dummy:
property = True

d = Dummy()
d.property = False
d.new = True

Stani
--
SPE - Stani''s Python Editor http://pythonide.stani.be


Robin Beckeraécrit:
Robin Becker a écrit :
有吗一种覆盖实例中数据属性的方法?我是否需要在更改属性的情况下创建另一个类?
Is there a way to override a data property in the instance? Do I need to
create another class with the property changed?




您的意思是属性还是属性?



Do you mean attributes or properties ?

2005年10月17日星期一18:52:19 +0100,Robin Becker< ro *** @ reportlab.com>写道:
On Mon, 17 Oct 2005 18:52:19 +0100, Robin Becker <ro***@reportlab.com> wrote:
有没有办法覆盖实例中的数据属性?我是否需要创建另一个属性已更改的类?
Is there a way to override a data property in the instance? Do I need to create
another class with the property changed?



如何覆盖?它?小心创建一个带有

的玩具示例希望我可以<覆盖动作>这里"评论线? ;-)


问候,

Bengt Richter


How do you need to "override" it? Care to create a toy example with a
"wish I could <override action> here" comment line? ;-)

Regards,
Bengt Richter


这篇关于覆盖一个属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆