I haven't created any classes from scratch before. Any previous ones have been super simple. Am I close to creating the class right? I'm confused on how to call an instance of the class. What I want to do is create a class Book
and assign various values (author name, home directory, output directory, function to get title, function to get .html files from home directory, etc). I want to create a new instance of class Book
for each bookList[i]
. bookList[i]
is each book's homeDir. What is my class and/or instance call missing please? Thanks in advance for all help or pointers.
class Book(obj):
def __init__(self, inc_dir):
self.home_dir = inc_dir
# self.author_name = aName
# self.target_dir = target_dir
# main #
bookList = getDirs(homeDir) # returns a list. works.
# print("len(bookList): ", len(bookList))
i = 0
while i <= len(bookList):
curBook = Book(bookList[i])
print("curBook name: " + curBook.home_dir)
print("Book Path: " + bookList[i])
i += 1
Traceback (most recent call last):
File "D:\Scripts\Python\batch content editing\html_book_builder.py", line 65, in <module>
class Book(obj):
NameError: name 'obj' is not defined