Professional IronPython



Download 20,35 Mb.
Pdf ko'rish
bet270/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   266   267   268   269   270   271   272   273   ...   453
 

 
257

main()
function. Essentially, you encase the code in Listing 12-1 in the 
main()
function and then 
call it using the following code:
# Create an entry point for debugging.
if __name__ == “__main__“:
main()
Using the debugger is very much like old-style DOS debuggers such as the Debug utility. You issue 
commands and the debugger responds without output based on the application environment and 
variable content. The lack of a visual display may prove troublesome to developers who have never 
used a character-mode debugger, but 
pdb
is actually more effective than any of the graphical alter-
natives in helping you locate problems with your application — at least, in the Python code. Use 
these steps to start the 
pdb
:
1.
Start the IronPython console by selecting it from the Start menu or typing 
IPY
at the
command line.
2.
Type 
import pdb
and press Enter to import the Python debugger.
3.
Type 
import 
ApplicationName
where 
ApplicationName
is the name of the file that 
contains your application and press Enter. For example, if your application appears in 
ShowFilters2.py
, then you’d type 
import ShowFilters2
(without the file extension)
and press Enter.
4.
Type 
pdb.run(‘
ApplicationName
.
FunctionName
()‘)
where 
ApplicationName
is the 
name of the application and 
FunctionName
is the name of the function you want to test, and 
press Enter. For example, if your application is named 
ShowFilters2
and the function you 
want to test is 
main()
, you’d type 
pdb.run(‘ShowFilters2.main()‘)
and press Enter. The 
standard console prompt changes to a 
pdb
prompt, as shown in Figure 12-9.
FIgURE 12-9: 
The Python debugger uses a special pdb prompt where you can enter debugging commands. 
Now that you have a debugger prompt, you can begin debugging your application. Here is a list of 
standard debugger commands you can issue:
➤➤
a or args: Displays the list of arguments supplied to the current function. If there aren’t any 
arguments, the call simply returns without displaying anything.


alias: Creates an alias for a complex command. For example, you might need to use a 
for
loop to drill down into a 
list
to see its contents. You could use an alias to create a com-
mand to perform that task without having to write the complete code every time. An alias 
can include replaceable variables, just as you would use for a batch file.
548592c12.indd 257
2/24/10 12:48:48 PM
www.finebook.ir



Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   266   267   268   269   270   271   272   273   ...   453




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish