0

Possible Duplicate:
Python modules with identical names (i.e., reusing standard module names in packages)

From a module inside a package, is there a way to ignore package context for a given import? since the package contains another module with same name as the one that's to be imported from the system, not from the package.

Is there a way to solve this without renaming the other module?

Community
  • 1
  • 1
oblitum
  • 11,380
  • 6
  • 54
  • 120
  • Can you give an example? If you are using absolute imports the default behavior is for the system package to be tried first. – BrenBarn Feb 02 '13 at 17:40
  • @BrenBarn I'm unable to use an absolute import in this case. It's a python VIM plugin, when python is loaded by VIM, I have available a module named simply `vim` that I can import at my scripts and modules. The thing is, I also have a submodule `mypackage.vim` and at module `mypackage.x` I want to `import vim`, but not the one from package, I want the one VIM provides. – oblitum Feb 02 '13 at 17:48
  • The main script has no problem using my `vim` module, since it uses it as `mypackage.vim.myfuction("hello world")`, it doesn't clash with `vim.vim_function()`. But the problem arises when I need to use `vim.vim_function()` from inside modules at my package. – oblitum Feb 02 '13 at 17:52
  • just flagged as duplicate of http://stackoverflow.com/q/10501473/1000282. – oblitum Feb 02 '13 at 18:07

1 Answers1

1

Have you tried...

import mypackage.vim as mypvim
import vim

You can use the "as" statement to provide another alias for something you import.

Jay Atkinson
  • 3,279
  • 2
  • 27
  • 41