Import Statements

April 22, 2008 § Leave a comment

Import statement is always different among programming languages. Not only the syntax, but also the concept of how codes are managed and called. Below are import statements from a couple of languages for your entertainment.


Python keeps track of its own modules (via PYTHONPATH) and perform import on those modules.

In Python, a module is just a file with definitions and statements. A module can also be a directory with in it.

There are multiple ways of using import syntax in Python:

  • import [identifier] #identifier can be Class, variable, or function name
  • from [module_name] import [identifier] #specify which module do you want to import from
  • from [module_name] import [identifier] as [alias] #alias your imported identifier
  • from [package_name.submodule_name] import [identifier] #in Python you can have modules inside a package

Interestingly, Modula-3 seemed to have the same style of importing as Python.


Now let’s move on to Ruby’s require.

Ruby found its libraries, and all modules inside them, by checking each directory inside $LOAD_PATH.

At first glance, Ruby seemed to just know where all its modules are. The require statement doesn’t need any description about path/location at all. Passing the path helps readability though.


There’s not much to say here.

In short, when PHP interprets, it will appends all the imported files and evaluates them all at once.

To import, use:

require_once [relative_path/file.php]


Perl import statement is called use. I am not a Perl expert, but here is the syntax:

use [module_name] [list_of_imported_things]


Disclaimer: I am not LISP expert, these are things that I’ve read.

LISP codes are broken into packages. To import those packages, use this syntax:

use-package [comma_seperated_packages]


Basically the syntax is:




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

What’s this?

You are currently reading Import Statements at RAPD.


%d bloggers like this: