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 in Python by ana1504.k
• 7,890 points
17 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 by SDeb
• 13,190 points

Related Questions In Python

0 votes
1 answer

How to display column names of Pandas Dataframe?

Suppose the name of your dataframe is df, ...READ MORE

answered May 12 in Python by Tony
57 views
0 votes
1 answer
+2 votes
3 answers

what is the practical use of polymorphism in Python?

Polymorphism is the ability to present the ...READ MORE

answered Mar 31, 2018 in Python by anto.trigg4
• 3,420 points
1,618 views
+4 votes
6 answers

Use of "continue" in python

The break statement is used to "break" ...READ MORE

answered Jul 16, 2018 in Python by Omkar
• 67,660 points
140 views
+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 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 349 views
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,190 points
316 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 21, 2018 in Python by SDeb
• 13,190 points
71 views