Maths sums formatting project

I am working on the Scientific Computing with Python course and I was wondering whether I could slightly alter the code that has been written in the main program so that the arithmetic_arranger function that I have written works. Instead of just importing arithmetic arranger, I would like to import * as I have created a new function that returns each of the items from my list.

Don’t alter the tests is the short answer. You’re writing code to spec, not specs to match code. main.py is part of the tests.

Besides, import * is almost always a bad idea.

I am not altering the tests. I am altering the import line only because I am creating a separate function for the result of the sum and validation. As a result, I may need to import all.

Also, if I may ask, why is import * almost always a bad idea?

We can quibble over whether it’s part of the test or not but it implements the checking of conformance with the specification and you should code to the spec. You can always write the required arithmetic_arranger function as an interface to your code you want to import.

Namespace pollution first and foremost. It also imports everything when most often you only need some parts of any given module. Most python linters flag this and sometimes its cousin from foo import * as well.

Never mind. I was trying to use high cohesion and strong coupling between the different functions but I guess I can still do the validation and the sums without the

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.