Python Forum
Using IntelliJ idea -- Classes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Using IntelliJ idea -- Classes
#1
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
Reply
#2
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.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Block comment in Intellij kam_uk 2 2,279 Nov-15-2020, 05:22 PM
Last Post: kam_uk
  Noobie Question, Libreries on Intellij donjon 2 3,051 Dec-16-2017, 01:59 PM
Last Post: Larz60+
  Using classes? Can I just use classes to structure code? muteboy 5 5,033 Nov-01-2017, 04:20 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020