MindBrain
MindBrain

Reputation: 7768

Python code has the following import

I cannot figure out what this import does and how to use it in the python code. I am new to python.

import datasources.google as google

Upvotes: 0

Views: 78

Answers (2)

Dan
Dan

Reputation: 12705

This line of code imports the module datasources.google. When you import a whole module with import whatevermodule, you have to include it every time you use a thing from that module, like so:

datasources.google.dowhatever(thing)

Since datasources.google is really long, it would be nice to have a short way of writing it. That's what the as google part does. It means you can instead write:

google.dowhatever(thing)

and saves you a bunch of typing.

Upvotes: 2

hd1
hd1

Reputation: 34677

Instead of writing datasources.google.method, you can now write google.method, see PEP221 for more details...

Upvotes: 2

Related Questions