I have a ‘processing’ function and a ‘serializing’ function. Currently the processor returns 4 different types of data structures to be serialized in different ways.
Looking for the best practise on what to do here.
def process(input): ... return a,b,c,d def serialize(a,b,c,d): ... # Different serialization patterns for each of a-d. a,b,c,d = process(input) serialize(a,b,c,d)
That feels janky.
Should I instead use a class where
a,b,c,d are member variables?
class VeryImportantDataProcessor: def process(self,input): self.a = ... self.b = ... ... def serialize(self): s3.write(self.a) convoluted_serialize(self.b) ... vipd = VeryImportantDataProcessor() vipd.process(input) vipd.serialize()
Keen to hear your thoughts on what is best here!
Note after processing and serializing, the code goes on to use variable
d for further unrelated shenanigans. Not sure if that changes anything.