python - Import a module into a module, can't explain what i'm trying to do -


so, following example. here's module (called feedy.py) in let's say, core directory:

import feedparser  feed = feedparser.parse("http://site.com/feed") [...] 

a bad example, anyway: problem in main script (parent dir), have do

import feedparser 

as as

from core import feedy 

however, there way eliminate need import feedparser, since it's imported in feedy.py?

hope understand, fike.

in principle, yes. however, it's not idea.

when import module, declare local variable reference module. in feedy have object called feedparser, happens module feedparser, although @ time reassign other python object.

when import feedy, can refer of feedy's exported variables feedy.name. in case, feedy.feedparser module feedparser.

however, if change way feedy implemented, doesn't import (or export) feedparser, break main script. in general don't want export have defined, although it's fine quick hack.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -