Logically/Selectively Sub Class?
Diez B. Roggisch
deets at nospam.web.de
Sun Mar 9 17:56:19 EDT 2008
More information about the Python-list mailing list
Sun Mar 9 17:56:19 EDT 2008
- Previous message (by thread): Logically/Selectively Sub Class?
- Next message (by thread): Logically/Selectively Sub Class?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
xkenneth schrieb: > On Mar 9, 4:38 pm, "Diez B. Roggisch" <de... at nospam.web.de> wrote: >> xkenneth schrieb: >> >>> Might be a silly question, but is it possible to selectively subclass, >>> IE subclass is a supporting module is present and not otherwise. >> Yes, something like this should work >> >> class Foo(some, base, classes) >> pass >> >> if condition: >> Temp = Foo >> class Foo(Temp, otherclass): pass >> >> Alternatively, you can use the type-function to create classes explicit >> with a list of base-classes. >> >> However it smells after bad design... what's your actual usecase? >> >> Diez > > Yeah, it's really a non-issue, just more a curiosity. I'm using ZODB > for a lot of my stuff now, and I need my objects to be persistent, > however there might be a case where my classes could be used in a non- > persistent manner. I'll just have ZODB as a requirement for my > package. Ah. Then this also might work try: from ZODB import Persistent except ImportError: class Persistent: pass Diez
- Previous message (by thread): Logically/Selectively Sub Class?
- Next message (by thread): Logically/Selectively Sub Class?
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list