[IPython-dev] IPython1 API design question

Barry Wark barrywark@gmail....
Fri Feb 8 16:25:05 CST 2008


What about two push/pull method pairs...

def push(self, **namespace):
   self.pushEx(namespace, block=<current_blocking_mode>, targets='all')
def pull(self, *keys):
   self.pullEx(keys, block= <current_blocking_mode>, targets='all')

and

pushEx(self, ns, block=True, target='all')
pullEx(self, keys, block=True, target='all')


Obviously I haven't put a lot of thought into the names, but the idea
is to provide a convenience method for the "expected" use case and an
extended method with more options.

barry

On Feb 8, 2008 2:12 PM, Stefan van der Walt <stefan@sun.ac.za> wrote:
> On Fri, Feb 08, 2008 at 09:16:25AM -0700, Brian Granger wrote:
> > The alternate API would look some thing like this:
> >
> > push(self, ns, block=True, targets='all')
> > pull(self, keys, block=True, targets='all')
> >
> > And be used:
> >
> > push(dict(a=10,b=30), block=False)      # targets = 'all'
> > pull(('a','b'))     # block=True, tagets='all'
> >
> > the main disadvantage is that a user has to manually build the dict
> > and tuple.  For pull, we could do a test to see if keys is a string
> > and build the tuple for then, but for the dict, they really have to
> > build it using dict or {}
> >
> > So, which of these approaches seems better, both from the development
> > and user's perspective?  Thoughts?
>
> For what it's worth, I like the idea of pushing namespaces.  With the
> current system, you can do (as a random example)
>
>   push(*_ip.user_ns)
>
> but then you have to make sure that the dict doesn't contain some
> special keywords.  I imagine it would be better to shield the user
> from such unexpected side-effects.
>
> Regards
> Stéfan
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev@scipy.org
> http://lists.ipython.scipy.org/mailman/listinfo/ipython-dev
>


More information about the IPython-dev mailing list