1

我无法获得在 Windows 中运行的 iPython 0.13.1 中显示当前工作目录的提示。如下所示,将当前工作目录更改为 后'C:\Users\Lou\Documents\Lou's Software\projects\loutilities'\Y3仅显示'C:/Users/Lou'. \w使用和{cwd}配置可以看到相同的行为。

我确定这是我正在做的愚蠢的事情,但我无法弄清楚,或者通过 Google 或 Stack Overflow 找到任何东西。

Python 2.7.1 (r271:86832, Nov 27 2010, 18:30:46) [MSC v.1500 32 bit (Intel)]
Type "copyright", "credits" or "license" for more information.

IPython 0.13.1 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object', use 'object??' for extra details.
[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-9572.json

C:/Users/Lou> cd "C:\Users\Lou\Documents\Lou's Software\projects\loutilities"
C:\Users\Lou\Documents\Lou's Software\projects\loutilities

C:/Users/Lou> config PromptManager
PromptManager options
-------------------
PromptManager.color_scheme=<Unicode>
    Current: u'Linux'
PromptManager.in2_template=<Unicode>
    Current: u'   .\\D.: '
    Continuation prompt.
PromptManager.in_template=<Unicode>
    Current: u'\\Y3> '
    Input prompt.  '\#' will be transformed to the prompt number
PromptManager.justify=<Bool>
    Current: False
    If True (default), each prompt will be right-aligned with the preceding one.
PromptManager.out_template=<Unicode>
    Current: u'Out[\\#]: '
    Output prompt. '\#' will be transformed to the prompt number

Thomas 要求输出os.getcwdu(). 我使用 config 命令更改了提示(我已经回到In [#n]提示),In [#n]提示仍然存在。线索?

In [1]: config PromptManager.in_template='\\Y3'

In [3]: config PromptManager
PromptManager options
-------------------
PromptManager.color_scheme=<Unicode>
    Current: u'Linux'
PromptManager.in2_template=<Unicode>
    Current: u'   .\\D.: '
    Continuation prompt.
PromptManager.in_template=<Unicode>
    Current: u'\\Y3'
    Input prompt.  '\#' will be transformed to the prompt number
PromptManager.justify=<Bool>
    Current: True
    If True (default), each prompt will be right-aligned with the preceding one.
PromptManager.out_template=<Unicode>
    Current: u'Out[\\#]: '
    Output prompt. '\#' will be transformed to the prompt number

In [4]: import os

In [5]: os.getcwdu()
Out[5]: u'C:\\Users\\Lou'

In [6]: cd weather
(bookmark:weather) -> C:\Users\Lou\Documents\Lou's Software\projects\weather
C:\Users\Lou\Documents\Lou's Software\projects\weather

In [7]: os.getcwdu()
Out[7]: u"C:\\Users\\Lou\\Documents\\Lou's Software\\projects\\weather"

原来的测试重复了……

C:/Users/Lou> cd weather
(bookmark:weather) -> C:\Users\Lou\Documents\Lou's Software\projects\weather
C:\Users\Lou\Documents\Lou's Software\projects\weather

C:/Users/Lou> import os

C:/Users/Lou> os.getcwdu()
      Out[3]: u"C:\\Users\\Lou\\Documents\\Lou's Software\\projects\\weather"

C:/Users/Lou> config PromptManager
PromptManager options
-------------------
PromptManager.color_scheme=<Unicode>
    Current: u'Linux'
PromptManager.in2_template=<Unicode>
    Current: u'   .\\D.: '
    Continuation prompt.
PromptManager.in_template=<Unicode>
    Current: u'\\Y3> '
    Input prompt.  '\#' will be transformed to the prompt number
PromptManager.justify=<Bool>
    Current: True
    If True (default), each prompt will be right-aligned with the preceding one.
PromptManager.out_template=<Unicode>
    Current: u'Out[\\#]: '
    Output prompt. '\#' will be transformed to the prompt number

11/21/12 - 检查get_ipython().prompt_manager.templates

C:/Users/Lou> pwd
      Out[1]: u'C:\\Users\\Lou'

C:/Users/Lou> get_ipython().prompt_manager.templates
      Out[2]:
{'in': u'{cwd_y[3]}> ',
 'in2': u'   .{dots}.: ',
 'out': u'Out[{color.number}{count}{color.prompt}]: '}

C:/Users/Lou> cd weather
(bookmark:weather) -> C:\Users\Lou\Documents\Lou's Software\projects\weather
C:\Users\Lou\Documents\Lou's Software\projects\weather

C:/Users/Lou> pwd
      Out[4]: u"C:\\Users\\Lou\\Documents\\Lou's Software\\projects\\weather"

C:/Users/Lou> get_ipython().prompt_manager.templates
      Out[5]:
{'in': u'{cwd_y[3]}> ',
 'in2': u'   .{dots}.: ',
 'out': u'Out[{color.number}{count}{color.prompt}]: '}
4

0 回答 0