Skip to content

? may generate hundreds of cell  #1349

Closed

Description

@Carreau

By mistake I have executed a cell like

for i in range(3):
    x= range?

but with ~70 instead of 3
which generated 70 code cell with just x= range in it...
it was really painfull to clean, it would be nice to prevent something like that

Activity

  1. takluyver commented on Jan 30, 2012

    @takluyver
    Member

    Ah, that's from a convenience I added for the console - if you do x=range?, it will show the help and put x=range at the next prompt so you can keep typing. It seems the notebook interprets that as making a new cell.

    That 'next prompt' action probably shouldn't happen for multiline cells. It should probably also be disabled for the notebook, but I don't know how much the kernel knows about the frontend it's talking to.

  2. Carreau commented on Jan 30, 2012

    @Carreau
    MemberAuthor

    Does the %loadpy function also use next_prompt ?

  3. takluyver commented on Jan 30, 2012

    @takluyver
    Member

    Yes, I believe it does.

  4. ellisonbg commented on Jan 31, 2012

    @ellisonbg
    Member

    this goes back to the IPython.zmq.zmqshell.ZMQInteractiveShell.set_next_input function. It is being called on each iteration of the loop with the string: " x=range?"

    What is this function for and any is it called each time ? is triggered? I did a quick grin and this set_next_input is called throughout the codebase. The notebook current creates a new cell with the contents of the payload. I didn't add any of this code, but would like to understand the logic behind all of this. @fperez, @minrk ?

  5. minrk commented on Jan 31, 2012

    @minrk
    Member

    This is how things like %loadpy work, for initializing the contents of the next input (cell). It should probably be implemented in a way that multiple calls within a single cell only result in one actual event. The most logical model is probably for each call to clobber the previous one, so that only the last call within a given execution actually has an effect.

  6. ellisonbg commented on Jan 31, 2012

    @ellisonbg
    Member

    OK, so this sounds like an issue with set_next_input itself, not the
    notebook. @takluyver can you investigate?

    On Mon, Jan 30, 2012 at 4:29 PM, Min RK
    [email protected]
    wrote:

    This is how things like %loadpy work, for initializing the contents of the next input (cell).  It should probably be implemented in a way that multiple calls within a single cell only result in one actual event.  The most logical model is probably for each call to clobber the previous one, so that only the last call within a given execution actually has an effect.


    Reply to this email directly or view it on GitHub:
    #1349 (comment)

    Brian E. Granger
    Cal Poly State University, San Luis Obispo
    [email protected] and [email protected]

  7. takluyver commented on Jan 31, 2012

    @takluyver
    Member

    Min's suggestion sounds sensible - this is how the terminal and the Qt console already work: set_next_cell sets an internal value, which is read when we produce the next prompt. I'll look into it, but it will be tomorrow, so if anyone else wants to take a crack at it in the meantime, go for it.

  8. added 2 commits that reference this issue on Nov 3, 2014
    d7bcc40
    26ab03c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions