Daniel
Daniel

Reputation: 1448

What is the proper way to write (and source?) .pdbrc file?

I tried to write a .pdbrc file in both Python 2.7 and Python 3.5, using a sample code provided in pdb doc, see below:

# Print instance variables (usage "pi classInst")
alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])
# Print instance variables in self
alias ps pi self

In my home directory, I open a file with nano .pdbrc and save the above code into it. Then I ran source .pdbrc and got the following error message:

-bash: .pdbrc: line 3: syntax error near unexpected token `('
-bash: .pdbrc: line 3: `alias pi for k in %1.__dict__.keys(): print("%1.",k,"=",%1.__dict__[k])'

How do I fix it?

Upvotes: 3

Views: 2655

Answers (1)

Daniel
Daniel

Reputation: 1448

@Mark Plotnick commented above and actually solved this problem for me.

  1. .pdbrc after written needs no source .pdbrc
  2. just save .pdbrc in home directory, and then it is ready to use in any python files when you run python -m pdb your_file.py

Upvotes: 2

Related Questions