← Back to team overview

dolfin team mailing list archive

Re: Setting docstring from another string...

 

Thanks Kristian!

Will try the first suggestion.

Johan


On Thursday September 22 2011 01:45:21 Kristian Ølgaard wrote:
> On 21 September 2011 19:08, Johan Hake <johan.hake@xxxxxxxxx> wrote:
> > Hello!
> > 
> > I think we have discussed this before, but I just tried setting a
> > docstring in the Python layer of dolfin from a generated docstring from
> > the cpp layer. I tried several different ways:
> > 
> >    def collapse(...):
> >        "dummy"
> > 
> > FunctionSpaceBase.collapse.__doc__ = cpp.FunctionSpace.collapse.__doc__
> 
> You need to access the collapse function through the
> FunctionSpaceBase.__dict__ to do this.
> 
> >    def collapse(...):
> >        cpp.FunctionSpace.collapse.__doc__
> 
> I think this fails because the docstring must be a string literal?
> 
> >    def collapse(...):
> >        __doc__ = cpp.FunctionSpace.collapse.__doc__
> 
> The last example only works for the class docstring (not functions).
> See below what you can do:
> 
> class A(object):
>     "A doc"
>     def f0(self):
>         "A f0 doc"
>     def f1(self):
>         "A f1 doc"
> 
> class B(object):
>     __doc__ = A.__doc__
> 
>     def f0(self):
>         pass
>     f0.__doc__ = A.f0.__doc__
> 
>     def f1(self):
>         pass
> 
> B.__dict__["f1"].__doc__ = A.f1.__doc__
> 
> help(B)
> 
> I would prefer the method used for setting f0.__doc__ over the method
> for f1.__doc__ when possible.
> 
> Kristian
> 
> > but none worked as expected. Any clues?
> > 
> > Johan
> > 
> > _______________________________________________
> > Mailing list: https://launchpad.net/~dolfin
> > Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> > Unsubscribe : https://launchpad.net/~dolfin
> > More help   : https://help.launchpad.net/ListHelp
> 
> _______________________________________________
> Mailing list: https://launchpad.net/~dolfin
> Post to     : dolfin@xxxxxxxxxxxxxxxxxxx
> Unsubscribe : https://launchpad.net/~dolfin
> More help   : https://help.launchpad.net/ListHelp


References