Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Relative import of submodule

In Python, how do I perform the equivalent of the following

import http.client

but using a relative import:

from . import http.client
import .http.client

For a package http in the current package? I want to then access the client module through it's parent name, http.client, as I would be able if I did the top level import.

like image 250
Matt Joiner Avatar asked Jan 17 '12 10:01

Matt Joiner


1 Answers

I think that what you're looking for is this:

from ..http import client
like image 124
jcollado Avatar answered Sep 24 '22 06:09

jcollado