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 8883701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:52:47+00:00 2026-06-14T20:52:47+00:00

I just started using Python and I have a question about idle vs terminal.

  • 0

I just started using Python and I have a question about idle vs terminal.

In idle, I made a file called Robot.py

I have a class called Robot

class Robot(object)

    def __init__(self,x,y):
        #some code here etc...

def HelloWorld()
    print "Hello World!"

I have another file called testrobot.py, which looks like so:

import Robot
r = Robot(1,4)

In idle, I am able to successfully create a Robot object when I run testrobot.py. However in terminal, it gives an error Message NameError: Robot is not defined

I’m not sure how to run my program in terminal.

Also:

How can I call my HelloWorld() function which is in Robots.py but not of the class Robot in an external file (such as testrobot.py)?

Thanks in advance!

  • 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-06-14T20:52:48+00:00Added an answer on June 14, 2026 at 8:52 pm

    When you load and run scripts in IDLE, they are automatically loaded for the interpreter. That means that as soon as you run the script in IDLE, the Python shell already has those types defined.

    When you want to run it from outside of IDLE, i.e. without running the module first, you need to import your Robot from that module. To do that, you import the module, not the type:

    import Robot
    myRobot = Robot.Robot(...)
    

    Or, if you want to use Robot directly, you need to use the from ... import syntax:

    from Robot import Robot
    myRobot = Robot(...)
    

    Similarily, you can call your function by using Robot.HelloWorld in the first case, or directly if you add HelloWorld to the import list in the second case:

    from Robot import Robot, HelloWorld
    myRobot = Robot(...)
    HelloWorld()
    

    As you can see, it is generally a good idea to name your files in lower case, as those are the module names (or “namespaces” in other languages).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started using/learning Python and have some questions. I have a text file
I'm a Python beginner and have just started using packages. When you're calling a
I've just started learning about Gimp scripting using Python, and was wondering, how do
I just started out using python and went straight to django. I have set
I have programmed in Python for a while, and just recently started using Ruby
I have just started using GAE (Python 2.7 SDK 1.6.4) , I have set
I just started using Eclipse but already I have a small problem. At first
I just started using rapidxml. I 1st create an xml file to read from.
I just started using mysqli API for PHP. Apparently, every time an object of
I just started using java so sorry if this question's answer is obvious. I

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.