May-22-2018, 11:50 AM
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
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