From 73c8422180d53c077a7065b6a1bfbf1f9dabcdc8 2006-01-27 23:56:32 From: vivainio Date: 2006-01-27 23:56:32 Subject: [PATCH] %quickref --- diff --git a/IPython/Magic.py b/IPython/Magic.py index fe32416..3f132dd 100644 --- a/IPython/Magic.py +++ b/IPython/Magic.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- """Magic functions for InteractiveShell. -$Id: Magic.py 1090 2006-01-27 21:24:05Z vivainio $""" +$Id: Magic.py 1092 2006-01-27 23:56:32Z vivainio $""" #***************************************************************************** # Copyright (C) 2001 Janko Hauser and @@ -2860,7 +2860,10 @@ Defaulting color scheme to 'NoColor'""" else: self.user_ns[par] = block print "Block assigned to '%s'" % par - + def magic_quickref(self,arg): + import IPython.usage + page(IPython.usage.quick_reference) + del IPython.usage # end Magic diff --git a/IPython/ipmaker.py b/IPython/ipmaker.py index d22ae9d..6ec1172 100644 --- a/IPython/ipmaker.py +++ b/IPython/ipmaker.py @@ -6,7 +6,7 @@ Requires Python 2.1 or better. This file contains the main make_IPython() starter function. -$Id: ipmaker.py 1088 2006-01-27 17:16:45Z vivainio $""" +$Id: ipmaker.py 1092 2006-01-27 23:56:32Z vivainio $""" #***************************************************************************** # Copyright (C) 2001-2006 Fernando Perez. @@ -405,6 +405,7 @@ object? -> Details about 'object'. ?object also works, ?? prints more. # 'profiles' are a shorthand notation for config filenames if opts_all.profile: + try: opts_all.rcfile = filefind('ipythonrc-' + opts_all.profile + rc_suffix, @@ -605,11 +606,19 @@ object? -> Details about 'object'. ?object also works, ?? prints more. # finally, try importing ipy_*_conf for final configuration try: import ipy_system_conf - import ipy_user_conf - except ImportError: + warn("Could not import 'ipy_system_conf'") pass - #IP.InteractiveTB() XXX uncomment in a later release + if opts_all.profile: + profmodname = 'ipy_profile_' + opts_all.profile + try: + __import__(profmodname) + except ImportError: + warn("Could not import '%s'" % profmodname) + try: + import ipy_user_conf + except ImportError: + warn('Could not import ipy_user_conf') # release stdout and stderr and save config log into a global summary msg.config.release_all() diff --git a/IPython/usage.py b/IPython/usage.py index 87a1c2f..1cdf38e 100644 --- a/IPython/usage.py +++ b/IPython/usage.py @@ -6,7 +6,7 @@ # the file COPYING, distributed as part of this software. #***************************************************************************** -# $Id: usage.py 998 2006-01-09 06:57:40Z fperez $ +# $Id: usage.py 1092 2006-01-27 23:56:32Z vivainio $ from IPython import Release __author__ = '%s <%s>' % Release.authors['Fernando'] @@ -597,3 +597,44 @@ MAIN FEATURES won't work: >>> x = ,my_function /home/me # syntax error """ + +quick_reference = r""" +IPython -- An enhanced Interactive Python - Quick Reference Card +================================================================ + +obj?, obj??, ?obj,??obj : Get help, or more help for object +?os.p* : List names in os starting with p + +Example magic: + +%alias d ls -F : 'd' is now an alias for 'ls -F' +alias d ls -F : Works if 'alias' not a python name +alist = %alias : Get list of aliases to 'alist' + +System commands: + +!cp a.txt b/ : System command escape, calls os.system() +cp a.txt b/ : after %rehash, most system commands work without ! +cp ${f}.txt $bar : Variable expansion in magics and system commands +files = ls /usr : Capture sytem command output +files.s, files.l, files.n: "a b c", ['a','b','c'], 'a\nb\nc' +cd /usr/share : Obvious, also 'cd d:\home\_ipython' works + +History: + +_i, _ii, _iii : Previous, next previous, next next previous input +_ih[4], _ih[2:5] : Input history line 4, lines 2-4 +_, __, ___ : previous, next previous, next next previous output +_dh : Directory history +_oh : Output history +%hist : Command history + +Autocall: + +f 1 2 : f(1,2) +,f 1 2 : f("1","2") +;f 1 2 : f("1 2") + +""" + + diff --git a/doc/ChangeLog b/doc/ChangeLog index 5af7ede..97e4cb9 100644 --- a/doc/ChangeLog +++ b/doc/ChangeLog @@ -21,6 +21,10 @@ * Magic.py: %store now allows doing %store foo > ~/myfoo.txt and %store foo >> ~/myfoo.txt to store variables to files (in clean textual form, not a restorable pickle). + + * ipmaker.py: now import ipy_profile_PROFILENAME automatically + + * usage.py, Magic.py: added %quickref 2006-01-25 Fernando Perez