Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 517495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:50:24+00:00 2026-05-13T07:50:24+00:00

Ruby uses require , Python uses import . They’re substantially different models, and while

  • 0

Ruby uses require, Python uses import. They’re substantially different models, and while I’m more used to the require model, I can see a few places where I think I like import more. I’m curious what things people find particularly easy — or more interestingly, harder than they should be — with each of these models.

In particular, if you were writing a new programming language, how would you design a code-loading mechanism? Which “pros” and “cons” would weigh most heavily on your design choice?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T07:50:24+00:00Added an answer on May 13, 2026 at 7:50 am

    The Python import has a major feature in that it ties two things together — how to find the import and under what namespace to include it.

    This creates very explicit code:

    import xml.sax

    This specifies where to find the code we want to use, by the rules of the Python search path.

    At the same time, all objects that we want to access live under this exact namespace, for example xml.sax.ContentHandler.

    I regard this as an advantage to Ruby’s require. require 'xml' might in fact make objects inside the namespace XML or any other namespace available in the module, without this being directly evident from the require line.

    If xml.sax.ContentHandler is too long, you may specify a different name when importing:

    import xml.sax as X
    

    And it is now avalable under X.ContentHandler.

    This way Python requires you to explicitly build the namespace of each module. Python namespaces are thus very “physical”, and I’ll explain what I mean:

    • By default, only names directly defined in the module are available in its namespace: functions, classes and so.
    • To add to a module’s namespace, you explicitly import the names you wish to add, placing them (by reference) “physically” in the current module.

    For example, if we have the small Python package “process” with internal submodules machine and interface, and we wish to present this as one convenient namespace directly under the package name, this is and example of what we could write in the “package definition” file process/__init__.py:

    from process.interface import *
    from process.machine import Machine, HelperMachine
    

    Thus we lift up what would normally be accessible as process.machine.Machine up to process.Machine. And we add all names from process.interface to process namespace, in a very explicit fashion.

    The advantages of Python’s import that I wrote about were simply two:

    • Clear what you include when using import
    • Explicit how you modify your own module’s namespace (for the program or for others to import)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 422k
  • Answers 422k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you have the Android SDK installed on the server,… May 15, 2026 at 11:13 am
  • Editorial Team
    Editorial Team added an answer You can do it with a custom ApplicationContext. Google reveals… May 15, 2026 at 11:13 am
  • Editorial Team
    Editorial Team added an answer Simple SQL select EmployeeId,count(*) from YourTable Group by EmployeeId May 15, 2026 at 11:13 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.