class instance customization
Steven D'Aprano
steve at REMOVE-THIS-cybersource.com.au
Sat Apr 17 10:32:17 EDT 2010
On Sat, 17 Apr 2010 13:09:43 +0400, Alexander wrote:
> Hi, list.
>
> I've some nontrivial class implementation MyClass and its instance my:
>
> my = MyClass(args)
>
> MyClass uses in internals some variable which is not defined in MyClass
> itself. I want to extend instance of MyClass at runtime defining this
> variable and making new instance. It is like a class inheritance in a
> static way
I'm afraid I don't understand what you are asking. MyClass uses a
variable which is not defined in MyClass. Where is it defined? Is it a
global variable?
What do you mean, "like a class inheritance in a static way"?
Perhaps you should give an example of what you want to happen.
> class MyNewClass(MyClass):
> def __init__(s, a):
> s._variable = a
>
> but this doesn't give me ability to make inheritance at runtime of the
> single parent intance.
Why not?
What is the single parent instance?
> Finaly this should look like this
>
> my = MyClass(args)
>
> a1 = my.new(1)
> a2 = my.new(2)
>
> and e.t.c. Is it possible to release this interface in python?
I'm afraid none of this makes any sense to me. What does the new() method
do?
--
Steven
More information about the Python-list
mailing list