Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to debug? #11

Closed
Chun-Yang opened this issue Jul 11, 2015 · 1 comment
Closed

How to debug? #11

Chun-Yang opened this issue Jul 11, 2015 · 1 comment
Labels

Comments

@Chun-Yang
Copy link

Thank you for your awesome challenges.

I am new to python, I know there is print and pdb.set_trace().

  1. Could you tell me where is the printed message?
  2. And how to make pdb.set_trace() work?
@donnemartin
Copy link
Owner

Hi Chun-Yang,

To debug just add the following line to the Code cell where you want the debugger to start:

import pdb; pdb.set_trace()

For example, you would add it like this:

def unique_chars_hash(string):
    import pdb; pdb.set_trace() # Start debugger when this line is hit
    chars_set = set()
    for char in string:
        if char in chars_set:
            return False
        else:
            chars_set.add(char)
    return True

Then run both the Code and Unit Test cells (either through the menu "Cell", or through a shortcut such as [shift + enter] or [control + enter].

This will drop you into the pdb debugger where you can issue commands like the following to l(ist) the source code:

l

or n(ext):

n

For a list of all pdb commands, refer to this link.

-Donne

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants