Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python "from xxx.yyy import xxx" error

Tags:

python

I'm working with the PyFacebook package in Python, and I've seen people mention numerous times that you can write an import statement as follows:

from facebook.djangofb import facebook

However, it does not work. It states that facebook.method_name exists in the facebook module, rather than the djangofb module. I assume I'm importing the facebook.method_name as facebook, not that I'm receiving it from the facebook package itself.

I'm using Python 2.6.

How can I alias facebook.djangofb as facebook?

like image 276
Bialecki Avatar asked Jan 11 '10 03:01

Bialecki


1 Answers

This is the proper way to alias a module via import:

import facebook.djangofb as facebook
like image 196
Andrew Hare Avatar answered Sep 21 '22 15:09

Andrew Hare