[IPython-dev] ipipe news
Walter Dörwald
walter at livinglogic.de
Thu Mar 2 17:21:57 EST 2006
John Hunter wrote:
>>>>>> "Walter" == Walter Dörwald <walter at livinglogic.de> writes:
> Walter> How about something like this: import ipipe
>
> Walter> class iinspect(ipipe.Pipe): def __xiter__(self, mode):
> Walter> fields = ("key", "value") for key in dir(self.input):
> Walter> yield ipipe.Fields( fields, key=key,
> Walter> value=getattr(self.input, key) )
>
> OK, great, that is enough to get me started
Basically you need a subclass/instance of ipipe.Table so the browser
kicks in automatically. But I'm thinking of changing this, so that the
existance of an __xiter__ attribute is enough to trigger the browser.
This would make it possible to add ipipe support without even having to
check if ipipe is available, and changing baseclasses if it isn't.
This Table/Pipe has to implement __xiter__() and the objects returned
from the iterator should implement __xattrs__() (which Fields does in a
standard way).
> Walter> I don't know where this comes from, are these the
> Walter> docstrings of the properties?
>
> Yes, the docstring has a standard formatting convention, eg
>
> def set_linewidth(self, w):
> """
> Set the line width in points
>
> ACCEPTS: float value in points
> """
> self._linewidth = w
>
>
> The inspector will look for lines starting with ACCEPTS: to generate
> the property list. I can hack your example to do the same.
>
> Thanks for the head start!
I'm looking forward to what you come up with.
Servus,
Walter
More information about the IPython-dev
mailing list