# Importing parts of Packages

Some programming languages offer the possibility of importing a single function from a library, as in

from x import y


I'm looking to import only one function (GraphCoordinates) from the GraphUtilities package.

The following commands do not work:

<< GraphUtilitiesGraphCoordinates

Needs["GraphUtilities", "GraphCoordinates"]


The former gives an error, while the latter loads the entire GraphUtilities package.

How should I proceed?

-

Block[{$ContextPath}, Needs["GraphUtilities"]]  (see this answer for an explanation), and then refer to your function by its long name: GraphUtilitiesGraphCoordinates  You can then go further and create an alias in your current context, if you don't want to type the long name: GraphCoordinates = GraphUtilitiesGraphCoordinates  Since the loaded package is not on the $ContextPath, this will not lead to shadowing. Note however that such aliases will work most of the time, but not always.
This workaround should work fine if you are ok to load the entire package and just don't want all its public functions to become public in your current context ("Global",or whatever it is). If you truly want to avoid even loading the entire package, you are (currently) out of luck.