How to do relative imports in python?



How to do relative imports in python?..

Answer / Shweta Srivastava

To perform relative imports in Python, you can use dot notation with either the `from` or `import` statements. Make sure that the package structure and import path match.nnHere's an example:nn``pythonn# parent/__init__.pynn# child1.pynfrom .child2 import Child2Classnn# child2.pynclass Child2Class:n passn``

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

Name few python web application frameworks?

1 Answers  


What is cgi in python?

1 Answers  


What are the benefits of python?

1 Answers  


What is blob in python?

1 Answers  


Is django an ide?

1 Answers  


Is python a programming?

1 Answers  


How do you use n in python?

1 Answers  


Can you use bootstrap with python?

1 Answers  


Which module(s) of python can be used to measure the performance of your application code?

1 Answers  


What are the different file-processing modes with python?

1 Answers  


Explain in detail – inheritance in python?

1 Answers  


What is a docstring?

1 Answers  


Categories