Neil Cerutti wrote:
> On 2006-10-18, neoedmund <[EMAIL PROTECTED]> wrote:
>> ivestgating the web, i found something similiar with my approch:
>> http://en.wikipedia.org/wiki/Duck_typing
>> "Duck-typing avoids tests using type() or isinstance(). Instead, it
>> typically employs hasattr() tests"
>
On 2006-10-18, neoedmund <[EMAIL PROTECTED]> wrote:
> ivestgating the web, i found something similiar with my approch:
> http://en.wikipedia.org/wiki/Duck_typing
> "Duck-typing avoids tests using type() or isinstance(). Instead, it
> typically employs hasattr() tests"
It's pity it didn't get calle
"neoedmund" <[EMAIL PROTECTED]> writes:
> Bruno Desthuilliers wrote:
> > neoedmund wrote:
> > > in real life, a class is not defined so well that any method is
> > > needed by sub-class.
> >
> > Then perhaps is it time to refactor. A class should be a highly
> > cohesive unit. If you find yourself
Bruno Desthuilliers wrote:
> neoedmund wrote:
> (snip)
> > So I can reuse a method freely only if it's worth reusing.
> > For the word "inheritance", in some aspect, meanings reuse the super
> > class, with the condition: must reuse everything from super class.
>
> Not really. In fact, inheritance
neoedmund wrote:
> ivestgating the web, i found something similiar with my approch:
> http://en.wikipedia.org/wiki/Duck_typing
> "Duck-typing avoids tests using type() or isinstance(). Instead, it
> typically employs hasattr() tests"
that's not entirely correct, though: in Python, duck-typing typ
Bruno Desthuilliers wrote:
> neoedmund wrote:
> (snip)
> > So I can reuse a method freely only if it's worth reusing.
> > For the word "inheritance", in some aspect, meanings reuse the super
> > class, with the condition: must reuse everything from super class.
>
> Not really. In fact, inheritance
neoedmund wrote:
(snip)
> So I can reuse a method freely only if it's worth reusing.
> For the word "inheritance", in some aspect, meanings reuse the super
> class, with the condition: must reuse everything from super class.
Not really. In fact, inheritance *is* a special case of
composition/deleg
On Oct 16, 9:01 pm, Bruno Desthuilliers <[EMAIL PROTECTED]> wrote:
> neoedmund wrote:
> > Bruno Desthuilliers wrote:
> >> neoedmund wrote:
> >> (*PLEASE* stop top-posting - corrected)
> >>> Ben Finney wrote:
> [Please don't top-post above the text to which you're replying.]
>
> "neoedmu
neoedmund wrote:
> Bruno Desthuilliers wrote:
>> neoedmund wrote:
>> (*PLEASE* stop top-posting - corrected)
>>> Ben Finney wrote:
[Please don't top-post above the text to which you're replying.]
"neoedmund" <[EMAIL PROTECTED]> writes:
> I'm trying to achieve a higher level
neoedmund wrote:
> Could you show some code to help me know how composition/delegation can
> be done here? Thanks.
Starting with your example C2 might just derive from C1 and perform a
supercall:
class C1(object):
def v(self, o):
return "expected "+o
class C2(C1):
Bruno Desthuilliers wrote:
> neoedmund wrote:
> (*PLEASE* stop top-posting - corrected)
> >
> > Ben Finney wrote:
> >> [Please don't top-post above the text to which you're replying.]
> >>
> >> "neoedmund" <[EMAIL PROTECTED]> writes:
> >>
> >>> I'm trying to achieve a higher level of "reusability"
neoedmund wrote:
(*PLEASE* stop top-posting - corrected)
>
> Ben Finney wrote:
>> [Please don't top-post above the text to which you're replying.]
>>
>> "neoedmund" <[EMAIL PROTECTED]> writes:
>>
>>> I'm trying to achieve a higher level of "reusability". Maybe it
>>> cannot be done in python? Can
Oh, How great is the solution! ( though i don't know how it works. )
Thank you George.
George Sakkis wrote:
> neoedmund wrote:
>
> > python use multiple inheritance.
> > but "inheritance" means you must inherite all methods from super type.
> > now i just need "some" methods from one type and "so
I found a dynamic way to inherite classes:
def MixIn(pyClass, mixInClass):
if mixInClass not in pyClass.__bases__:
pyClass.__bases__ += (mixInClass,)
def test1():
o = C3()
MixIn(C3,C1)
MixIn(C3,C2)
o.m()
"expected aaa"
neoedmund wrote:
> thank you, Ka
neoedmund wrote:
> python use multiple inheritance.
> but "inheritance" means you must inherite all methods from super type.
> now i just need "some" methods from one type and "some" methods from
> other types,
> to build the new type.
> Do you think this way is more flexible than tranditional inh
neoedmund schrieb:
> python use multiple inheritance.
> but "inheritance" means you must inherite all methods from super type.
> now i just need "some" methods from one type and "some" methods from
> other types,
> to build the new type.
> Do you think this way is more flexible than tranditional in
python use multiple inheritance.
but "inheritance" means you must inherite all methods from super type.
now i just need "some" methods from one type and "some" methods from
other types,
to build the new type.
Do you think this way is more flexible than tranditional inheritance?
Ben Finney wrote:
[Please don't top-post above the text to which you're replying.]
"neoedmund" <[EMAIL PROTECTED]> writes:
> I'm trying to achieve a higher level of "reusability". Maybe it
> cannot be done in python? Can anybody help me?
What, specifically, are you trying to achieve? What problem needs
solving?
I'm trying to achieve a higher level of "reusability". Maybe it cannot
be done in python? Can anybody help me?
Ben Finney wrote:
> "neoedmund" <[EMAIL PROTECTED]> writes:
>
> > There's a program, it's result is "unexpected aaa", i want it to be
> > "expected aaa". how to make it work?
> >
> > [co
thank you, Kay.
But i need a "dynamic" way. Say i have a existing class, and add some
method from other class into it.
Kay Schluehr wrote:
> neoedmund wrote:
> > There's a program, it's result is "unexpected aaa", i want it to be
> > "expected aaa". how to make it work?
> >
> > [code]
> >
> > cl
neoedmund wrote:
> There's a program, it's result is "unexpected aaa", i want it to be
> "expected aaa". how to make it work?
>
> [code]
>
> class C1(object):
> def v(self, o):
> return "expected "+o
>
> class C2(object):
> def v(self, o):
> return "unexpecte
"neoedmund" <[EMAIL PROTECTED]> writes:
> There's a program, it's result is "unexpected aaa", i want it to be
> "expected aaa". how to make it work?
>
> [code]
>
> class C1(object):
> def v(self, o):
> return "expected "+o
>
> class C2(object):
> def v(self, o):
>
There's a program, it's result is "unexpected aaa", i want it to be
"expected aaa". how to make it work?
[code]
class C1(object):
def v(self, o):
return "expected "+o
class C2(object):
def v(self, o):
return "unexpected "+o
def m(self):
23 matches
Mail list logo