Python Forum

Full Version: Using IntelliJ idea -- Classes
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi All,

I am brand new to python coding , having previously worked with c# and vb.

I hope this is not too basic a question...I have installed Intellij IDEA as my editor.

I have created a class called headFirstA --With very simple code as below

class headFirstA:
def __init__(self,name=''):
self.name=name


def printAll(self,theList,level=0):
for eachItem in theList:
if isinstance(eachItem,list):
print(eachItem)
else:
for tabStop in range(level):
print("\t",end='')
print(eachItem)

I am simply trying to call this from another file within the same solution. As you can see I am trying to follow a tutorial.


from headFirstA import *
movies = ["The Holy Grail", 1975, "Terry Jones & Terry Gilliam", 91,
["Graham Chapman", ["Michael Palin", "John Cleese",
"Terry Gilliam", "Eric Idle", "Terry Jones"]]]

h =headFirstA("HeadFirst")
h.printAll(movies,0)

error messge I get is "AttributeError: 'headFirstA' object has no attribute 'printAll'"

Thanks for any information, or if anyone has any good resources on working with classes in python...that would be great.

Cheers

Aidan
Welcome to Python and the forums!
First, please put your code in Python code tags and full error traceback message in error tags. You can find help here.