How can I define .pdbrc on a Windows machine?

落花浮王杯 提交于 2020-03-21 20:13:27

问题


How can I define .pdbrc on my Windows machine?

My .pdbrc file:

alias sl s;;l
alias nl n;;l
alias cl c;;l

After reading the answer to this question, I tried putting it in C:\Users\<my_user>. Starting pdb (using pdb.set_trace()), I tried the aliases. They weren't recognized.

I'd like to know how to set a .pdbrc both globally, and for a virtual environment.


回答1:


pdb looks for the HOME system variable which is not defined by default in Windows. You have to define it yourself.

This issue arises because every user in a *nix operating system (Linux, Unix, Darwin, etc.) has a /home directory where they can put run codes like .pdbrc. The path to this directory lives in a system variable (HOME) that applications use to point to a user's personal files. Windows doesn't really have anything like that. The closest analogy to /home on Windows is probably C:\Users\<username>.

Here is how to define a HOME system variable that contains the path C:\Users\<username>. Left click on the startup button and then right click on "Computer" and select "Properties".

On the top left, click the "Advanced system settings" link.

This brings up the "System Properties" dialog. On the "Advanced" tab, press the "Environment variables..." button.

This brings up the "Environment Variables..." dialog. In the top section for "User variables for <username>", press the "New..." button.

For "Variable name:" put "HOME" and for "Variable value:" put C:\Users\<username>.

If a HOME variable already exists, just put a semi-colon between whatever is the current value and the new path. When an application uses the HOME variable, it will likely search the contents sequentially. If you want your new path to be found first, put it first in the list.

Hit "Okay" a bunch and then restart whatever application (cmd.exe or otherwise) is running pdb. Make sure that your .pdbrc file is in C:\Users\<username>. When you run pdb again, it should now read your .pdbrc file on startup.



来源:https://stackoverflow.com/questions/35229303/how-can-i-define-pdbrc-on-a-windows-machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!