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

Popular posts from this blog

javascript - oscilloscope of speaker input stops rendering after a few seconds -

javascript - gulp-nodemon - nodejs restart after file change - Error: listen EADDRINUSE events.js:85 -

Fatal Python error: Py_Initialize: unable to load the file system codec. ImportError: No module named 'encodings' -