module - How to import a Python class that is in a directory above? -


I want to inherit a file from that file which is currently in the directory above.

Is it possible to import this file relatively?

Inside a package hierarchy, use two points, as the Doctor says:

When you specify the module for importing, you do not have to specify the full name of the module. When a module or package is included in another package, it is possible to import a relative within the same package without mentioning the package name. By using the leading points in the module or package specified by you can specify how high the current package range is in order without specifying the exact name. A leading dot means the current package where the importing module is present. Two points mean a package level Three points are two levels, etc. If you execute with import mod from a module in the pkg package, then you will stop importing pkg.mod . If you execute with with pkg.subpkg1 you will import pkg.subpkg2.mod . The specification contained for the relative import.

relates to full / relative import.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -