- Mastering Python Scripting for System Administrators
- Ganesh Sanjiv Naik
- 197字
- 2021-07-02 14:00:32
Within an interpreter
To start the debugger from the Python interactive console, we are using run() or runeval().
Start your python3 interactive console. Run the following command to start the console:
$ python3
Import our pdb_example script name and the pdb module. Now, we are going to use run() and we are passing a string expression as an argument to run() that will be evaluated by the Python interpreter itself:
student@ubuntu:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pdb_example
>>> import pdb
>>> pdb.run('pdb_example.Student(5).print_std()')
> <string>(1)<module>()
(Pdb)
To continue debugging, enter continue after the (Pdb) prompt and press Enter. If you want to know the options we can use in this, then after the (Pdb) prompt press the Tab key twice.
Now, after entering continue, we will get the output as follows:
student@ubuntu:~$ python3
Python 3.5.2 (default, Nov 23 2017, 16:37:01)
[GCC 5.4.0 20160609] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> import pdb_example
>>> import pdb
>>> pdb.run('pdb_example.Student(5).print_std()')
> <string>(1)<module>()
(Pdb) continue
0
1
2
3
4
>>>
推薦閱讀
- Learn Type:Driven Development
- Java高手真經(jīng)(高級(jí)編程卷):Java Web高級(jí)開發(fā)技術(shù)
- Neo4j Essentials
- Swift 3 New Features
- Building Mapping Applications with QGIS
- Functional Kotlin
- 基于Swift語(yǔ)言的iOS App 商業(yè)實(shí)戰(zhàn)教程
- OpenGL Data Visualization Cookbook
- JBoss:Developer's Guide
- Scala Functional Programming Patterns
- JQuery風(fēng)暴:完美用戶體驗(yàn)
- Qt 4開發(fā)實(shí)踐
- Web開發(fā)的平民英雄:PHP+MySQL
- Getting Started with SQL Server 2014 Administration
- Java Web開發(fā)系統(tǒng)項(xiàng)目教程