[IPython-dev] Re: ipython: patch to implement @bookmark, @cdb magics

Fernando Perez Fernando.Perez at colorado.edu
Tue Jun 29 16:14:19 CDT 2004


Ville Vainio wrote:
> Fernando Perez wrote:
> 
> 
>>I'd actually prefer to implement the 'cd to bookmark' via a -b option 
>>to @cd instead of as a wholesale new magic.  It keeps the 
>>functionality nicely together, and it makes it more likely that people 
>>will actually use it.
> 
> 
> Hmm, I'd kinda like to have it as cdb. It's much faster to type, and I 
> implemented it in anticipation of frequent directory switching back and 
> forth, like cdb foos [foo source], do some stuff there, cdb fooh [foo 
> header], do other stuff there.

-1

I really try to keep the number of builtin magics under control.  Especially 
since it's so trivial to write a one-line magic in your own config file that 
delegates (pseudo code below):

def magic_cdb(foo):
   self.magic_cd('-b %s' % foo)

I actually have a bunch of such 'private' magics to suit my own personal 
taste, but I don't include them in the distribution.  It's better to 
distribute a few flexible functions, and let the hacker/twiddler-minded ones 
(like myself) do the fine-tuning on their own.  The builtin magic list is 
large enough as it is.

But overall I like the patch quite a bit, along with the idea for a persistent 
storage pickle.  This can be extended later to many things.  I'll have to 
think about whether to have that name be tied to a profile or not, you might 
want your bookmarks to be general, or not.  I'm not really sure.

> Well, the new patch I've attached implements it that way anyway ;-). I 
> also removed the persistent file as config option; I just couldn't get 
> the config system working :-/. I guess it could be implemented as config 
> option once the config system is fixed, i.e. python-based configuration 
> files are implemented.

The config option has to be initialized in ipmaker.py.  That stuff is a mess, 
which is why I want to rewrite it.  The reason it's so ugly, is because it 
used to be my $PYTHOSTARTUP file, which eventually became an object initalizer 
routine.  But all of that needs to go into the underlying object itself.

There's no rush, I doubt I'll get to work on these patches before the weekend. 
    So feel free to play with them further.  But I think it's a really nice 
idea, so keep going.

Best,

f




More information about the IPython-dev mailing list