I am working on getting more into python classes. I see the benefit but have been stuck in my old ways. I have new project that this would be perfect for but I am having an issue translating it across. From all the documentation this should work and is set up just like the example.
I have two scripts. My main script and then a script that contains my classes
Main Script:
import arcpy
import os
import sys
import Addressing_Class_Modules
workspace = r"C:UsersjconshickDesktopProject_Centerlines"
folderName = "Locator"
a = Addressing_Class_Modules.Locator(workspace=workspace, folderName=folderName)
print(a.CheckLocatorFolder())
Class:
import arcpy
import os
import sys
class Locator:
def __init__(self, workspace, folderName):
self.workspace = workspace
self.folderName = folderName
def CheckLocatorFolder(self):
path = arcpy.Describe(self.workspace).path
return arcpy.Exists(os.path.join(path, self.folderName))
The documentation says I am doing it correctly or what I have come to understand as correct. When I use the example it works and mine does not. I would appreciate some insight on the matter. This is the error:
TypeError Traceback (most recent call last)
[Path Redacted]Address_Class_Test.py in <cell line: 14>()
12 folderName = "Locator"
13 a = Addressing_Class_Modules.Locator(workspace=workspace, folderName=folderName)
---> 14 print(a.CheckLocatorFolder())
TypeError: CheckLocatorFolder() missing 2 required positional arguments: 'workspace' and 'folderName'
'''