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

  • Home
  • SEARCH
  • 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 8514357
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T04:50:41+00:00 2026-06-11T04:50:41+00:00

I am working my way through the excellent ‘Python The Hard Way’ and copied

  • 0

I am working my way through the excellent ‘Python The Hard Way’ and copied the following code into a file called mystuff.py:

class MyStuff(object):

    def __init__(self):
        self.tangerine = "And now a thousand years between"

    def apple(self):
        print "I AM CLASSY APPLES!"

In terminal:

import mystuff

thing = MyStuff()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'MyStuff' is not defined

This has been happening repeatedly with other simple classes today. Can someone tell me what I am doing wrong?

  • 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-11T04:50:42+00:00Added an answer on June 11, 2026 at 4:50 am

    You probably want thing = mystuff.MyStuff() (assuming mystuff is the name of the file where the class MyStuff resides).

    The issue here is with how python handles namespaces. You bring something into the current namespace by importing it, but there’s a lot of flexibility in how you merge the namespaces from one file into another. For example,

    import mystuff
    

    brings everything from the mystuff (module/file level) namespace into your current namespace, but to access it, you need mystuff.function_or_class_or_data. If you don’t want to type mystuff all the time, you can change the name you use to reference it in the current module (file):

    import mystuff as ms
    

    now, you can acess MyStuff by:

    thing = ms.MyStuff()
    

    And (almost) finally, there’s the from mystuff import MyStuff. In this form, you bring MyStuff directly into your namespace, but nothing else from mystuff comes into your namespace.

    Last, (and this one isn’t recommended) from mystuff import *. This works the same as the previous one, but it also grabs everything else in the mystuff file and imports that too.

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

Sidebar

Related Questions

Working my way through Learn Python the Hard Way ex.25, and I just can't
I am working my way through Learn Python the Hard Way and am stuck
Im working my way through some C++ code and came across the following void
I'm working my way through Zed Shaw's Learn Python The Hard Way. I'm up
I am working my way through a Spring tutorial, I have the following code,
I'm working my way through Agile Web Development with Rails and am running into
I am working my way through Eloquent Javascript and I came across a code
I have been working my way through Scott Guthrie's excellent post on ASP.NET MVC
I'm currently working my way through the excellent Tour of Go . I finished
I am working my way through a book called Head First C#. It doesnt

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.