Interesting article on programming languages
Sami Hangaslammi
shang.remove_edu at st.jyu.fi.edu
Thu Jan 27 05:46:43 EST 2000
Roey Katz <katz at glue.umd.edu> wrote in message
news:388f88ca.1925884 at news.erols.com...
> The 'virtual classes' that Sweeney describes look to me an awful lot
> like something like this:
>
>
> class myClass:
> def __init__( self ): pass
> def doSomething( self ): print 'instantiating'
>
> class myClass2:
> def __init__( self ): pass
> def doSomething( self ): print 'instantiating (2)'
>
> class Base:
>
> virtualClass = None
>
> def __init__( self ):
> self.inst = self.virtualClass()
> self.inst.doSomething()
>
>
> class Derived1( Base ):
> virtualClass = myClass
>
> class Derived2( Base ):
> virtualClass = myClass2
I was thinking about something along these lines:
class SomeFramework:
class Class1:
def some_method(self):
print "original class1"
class Class2:
pass
def __init__(self):
self.c1 = self.Class1()
self.c2 = self.Class2()
class DerivedFramework (SomeFramework):
class Class1 (SomeFramework.Class1):
def some_method(self):
print "derived class1"
Now DerivedFramework can inherit SomeFramework and modify Class1 how
ever it wants.
--
Sami Hangaslammi
shang (at) st (dot) jyu (dot) fi
Get paid to surf the Web!
http://www.alladvantage.com/home.asp?refid=BOT021
More information about the Python-list
mailing list