I’ve searched around other threads with similar questions, but I’m not finding the answer. Basically, I have a class:
import Android_Class
class Android_Revision(object):
def __init__(self):
# dict for storing the classes in this revision
# (format {name : classObject}):
self.Classes = {}
self.WorkingClass = Android_Class()
self.RevisionNumber = ''
def __call__(self):
print "Called"
def make_Class(self, name):
newClass = Android_Class(name)
self.Classes.update({name : newClass})
self.WorkingClass = newClass
def set_Class(self, name):
if not(self.Classes.has_key(name)):
newClass = Android_Class(name)
self.Classes.update({name : newClass})
self.WorkingClass = self.Classes.get(name)
I’m trying to make an instance of this class:
Revision = Android_Revision()
and that’s when I’m getting the error. I’m confused because I have another situation where I’m doing almost the exact same thing, and it’s working fine. I can’t figure out what differences between the two would lead to this error. Thanks.
I second the comments, this question lacks important information, and if this error wasn’t insanely common and had rather distinctive symptoms, I wouldn’t be able to provide anything resembling an answer.
Python’s view on {files,modules} and classes is quite different from Java’s. A module is a higher-level unit of organization than classes. Specifically, a module may contain any number of classes (among numerous other things).
importdeals with modules, not with classes.import foogives you the module of that name, regardless of any classes of that name. If you must have a class in a module of the same name (quite often, this is a sign of overusing classes or ignoring modules as unit of organization), you either access it asFoo.Fooor you dofrom Foo import Foo.By the way, module names should be
lower_casewhile class names should bePascalCase. Don’t mix the two. Also read PEP 8 for other conventions.