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
• 6,110 points
6 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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
• 9,660 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
7 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
969 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
• 65,850 points
36 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
25 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
• 9,660 points
101 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
• 9,660 points
22 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.