I would like to ask you to help me out with my factory method. I have to handle multiple and periodic csv objects, each of which has its own properties, thus its own class. The only way I can tell Python one csv differs from another, is due to the file name. Now, I create different object based on the file name, as follows:
class CSVFileFactory: @staticmethod def obj_builder(fname: str): if "type1" in fname: return TypeOneCSV(filename=fname) elif "type2" in fname: return TypeTwoCSV(filename=fname) elif "type3" in fname: return TypeThreeCSV(filename=fname) ... ... And so on. Do you think this is the cleanest way I could do it? Are there any conventions I'm not applying? Do you have any suggestion to reduce code complexity and the never-ending "if-elif" statement? Thanks a lot for the help!
class CSVFileFactory:no. Python is not Java. This should just be a function. A class with a single staticmethod should just be a functiondictinstead, but I don't think that really gives you much of an advantage