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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:38:12+00:00 2026-05-29T22:38:12+00:00

I have defined c:/temp/t.py as follows: class MyClass(object): def __init__(self): self._my_secret_thing = 1 def

  • 0

I have defined c:/temp/t.py as follows:

class MyClass(object):
    def __init__(self):
        self._my_secret_thing = 1

    def _i_get(self):
        return self._my_secret_thing

    def _i_set(self, value):
        self._my_secret_thing = value

    def _i_delete(self):
        print 'neh!'
        #del self._my_secret_thing

    my_thing = property(_i_get, _i_set, _i_delete,'this document for my_thing')

Then I use Python Shell 2.4.4 as follows:

>> import sys
>>> sys.path.append('c:/temp')
>>> import t
>>> dir(t)
['MyClass', '__author__', '__builtins__', '__doc__', '__file__', '__name__']
>>> t = MyClass()
Traceback (most recent call last):
  File "<pyshell#11>", line 1, in -toplevel-
    t = MyClass()
NameError: name 'MyClass' is not defined

Question> Why python shell cannot find ‘MyClass’?

  • 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-29T22:38:13+00:00Added an answer on May 29, 2026 at 10:38 pm

    You import a module called t. Because of namespacing, everything defined in t has to be accessed through it.

    import t
    inst = t.MyClass()
    

    If you want to just get the class and discard everything else in the t module, you can do that like so.

    from t import MyClass
    inst = MyClass()
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have defined an interface in C++, i.e. a class containing only pure virtual
I have defined the global nls_date_format on Oracle 10.2 XE as follows: alter system
I have defined a class A and derived a new class B from A
I've defined some signal: typedef boost::signals2::signal<void (int temp)> SomeSig; typedef SomeSig::slot_type SomeSigType; I have
I defined a method for rendering pages: def doRender(handler, tname='index.html',values = {}): temp =
I have defined a createdirectory(const stdStr& path) in a class and I am accessing
I have an ActiveX HTML Object as defined here: <object id=HSMBTPrintX1 width=350 height=350 classid=CLSID:68d05400-18a6-4b39-b3ff-a17d77c1eddf
I have a character array defined in a header //header.h const char* temp[] =
I have a temp table, let's call it #invoices, defined as create table (id
I have defined a custom Sharepoint list for special attributes related to a software

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.