Skip to content

Error if %s is not present in prompt string format #442

@fcollonval

Description

@fcollonval

Hey,

I was trying to hide the prompt by setting an empty string to nbsphinx_input_prompt. This results in a TypeError on:

prompt = prompt_template % (execution_count,)

The blame is the % format. Would you consider switching to format asking user to set the string as "In [{}]" rather than "In [%s]". This will be more robust, see:

In [6]: "hello" % "dummy"
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-a2bd27e7e4d9> in <module>
----> 1 "hello" % "dummy"

TypeError: not all arguments converted during string formatting

In [7]: "hello".format("dummy")
Out[7]: 'hello'

In [8]: "hello {}".format(12)
Out[8]: 'hello 12'

Another possibility would be to test for %s.

Note: I use that workaround for my initial purpose.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions