[prev in list] [next in list] [prev in thread] [next in thread] 

List:       pykde
Subject:    [PyKDE] Spiffy stuff...
From:       dan <dan () eevolved ! com>
Date:       2000-12-24 13:44:39
[Download RAW message or body]

I read stuff about subclassing and references and I thought maybe this stuff 
could help someone else...

I could explain, or you could look at the code :)

----------------------
from qt import *

class PatchedQString(QString):
    def output(self):       # new method that you want to add in qstring
        print eval(`self`)

    def utf8(self):         # method you want to 'patch'
        print "requested utf8"
        return QString.utf8()

QString = PatchedQString    # patch existing class

newvar = QString(u"Here is some initializer string")
newvar.output()         # call new method
print newvar.utf8()     # prints out "requested utf8() AND
                              # returns the classic QString.utf8()

-----------------------

I'm sure you could think of a use for this :-)

Dan


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic