Display details of importer

0 votes
In Django I have a package that issues a deprecation warning. sHow to make sure that the warning described where the import was being made from, so the coder can go in and change the file without having to step through code to find it?

So the general case is

#file1.py
import file2.py

#file2.py
import warnings
warnings.warn(
'Package deprecated: imported from %s' % __importer__,
DeprecationWarning
)
 

Where __importer__ is an imaginary attribute containing "file1.py", or some such reference.

Can anyone help me with this?
Mar 15, 2019 in Python by ana1504.k
• 7,910 points
661 views

1 answer to this question.

0 votes
Yes, you can perform the same by using the stacklevel argument to warnings.warn

I hope this helps!
answered Mar 15, 2019 by SDeb
• 13,300 points

Related Questions In Python

+1 vote
2 answers

How to display column names of Pandas Dataframe?

print(list(your_df)) READ MORE

answered Jan 18, 2020 in Python by anonymous
22,186 views
0 votes
1 answer
0 votes
0 answers

Excel .json Import Error: The Type of Current Preview Value is Too Complex to Display

Main Problem: I'm trying to import .json to excel ...READ MORE

Mar 15, 2020 in Python by Tarık
• 120 points
1,617 views
0 votes
1 answer
0 votes
2 answers
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,358 views
0 votes
1 answer
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 13,300 points
2,307 views
0 votes
1 answer

Return a list inside a for loop while iterating over the elements of another list

The print() is getting called multiple times ...READ MORE

answered Sep 22, 2018 in Python by SDeb
• 13,300 points
4,956 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP