Professional IronPython


Understanding IronPython Warnings



Download 20,35 Mb.
Pdf ko'rish
bet259/453
Sana01.07.2022
Hajmi20,35 Mb.
#723045
1   ...   255   256   257   258   259   260   261   262   ...   453
Understanding IronPython Warnings
 

 
245
FIgURE 12-2: 
You can set the warning to appear every time.
Unfortunately, as shown in the figure, the change affects every message. Using the 
simplefilter()
function affects every message in every module for a particular message category. Both the 
newmessage
and 
deprecated
messages always appear. Let’s say you want to make just the deprecated message always 
appear. To perform this task, you use the 
filterwarnings()
function as shown in Figure 12-3 (after 
first resetting the category using the 
resetwarnings()
function).
FIgURE 12-3: 
Use the filterwarnings() function when you need better control over filtering.
In this case, the 
warnings.warn(“deprecated“, DeprecationWarning)
warning appears every time because its action is set to 
always
. However, the 
warnings 
.warn(“newmessage“, DeprecationWarning)
warning appears only once because it uses
the default action.
You can also set an action at the command line using the 
–W
 command line 
switch. For example, to set the interpreter to always display warning messages, 
you’d use the 
–W always
 command line switch. The 
–W
 command line switch 
accepts an action, message, category, module, or line number (lineno) as input. 
You can include as many 
–W
 command line switches as needed on the command 
line to filter the warning messages.
548592c12.indd 245
2/24/10 12:48:45 PM
www.finebook.ir


246

CHAPTER 12
Debugging ironPython APPlicAtions
The 
resetwarnings()
function affects every warning category and every message in every module. 
You might not want to reset an entire filtering configuration by using the 
resetwarnings()
function. 
In this case, simply use the 
filterwarnings()
or 
simplefilter()
function to set the warning back 
to the default action.
At this point, you might wonder how to obtain a list of the filters you’ve defined. For that matter, 
you don’t even know if there are default filters that the interpreter defines for you. Fortunately, the 
warnings
class provides two attributes, 
default_action
and 
filters
, which provide this informa-
tion to you. Listing 12-1 shows how to use these two attributes.

Download 20,35 Mb.

Do'stlaringiz bilan baham:
1   ...   255   256   257   258   259   260   261   262   ...   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