python - Customized Trait built from multiple inheritance -
i trying create custom trait represents unipath.path object. seems advantageous re-use machinery provided file trait, thought use multiple inheritance.
from unipath import path traits import file class pathtrait(path,file): pass class a(hastraits): p = pathtrait()
however, when used via a(p='/tmp/')
, a.p
not have methods associated path
object, expect. should implementing get
, set
methods?
what expect a(p='/tmp')
should do?
i can tell trying statement should fail typeerror
if code correct. instead of type error, replacing variable p on a
object, instance of pathtrait
, string.
what you're trying conceptually mixed up. file
class represents trait object. technically python allows extend object, because python has little type safety, doesn't mean python class act trait.
to define custom traits need use tools designed operate traits such trait
constructor.
Comments
Post a Comment