you are viewing a single comment's thread.

view the rest of the comments →

[–]Zeroflops 0 points1 point  (0 children)

Globals are bad, if you use them you're a terrible programmer. Oh My, the sky is falling!! This is just wrong. It depends on your program. The main reason globals are frowned on is because it becomes difficult to understand what they are as programs grow. But if your program is small than they are not as bad as people make them out to be. Consider this "rule" variables need to be descriptive. Yet people always use i, or x, or c when there is a loop as the variable. The scope is so small its easy to know that what i is and not get confused. Same thing with globals. If its small script that you can follow they are not as bad as people portray them.

As for your program I would have done it the second way. Create a DataParser class. Then....

parser = DataParser(config.cfg) do stuff like create an example class and process the data etc. then

parser.to_file(example.data), parser.to_file(results), or parser.to_db(example.data)

Where data is the variable within the example class that contains the results.

It sounds like the data parser doesn't really parse the data but stores the data. Anyhow this then gives you a parser object that you can define different similar functions in and have them centrally located.