[Tutor] problem with creating paths

Shall, Sydney sydney.shall at kcl.ac.uk
Wed Oct 17 10:18:00 EDT 2018


I am a novice (at programming).
I use MAC OS 10.13.6
Anaconda.
Python 3.5.4
Spyder 3.5.6

I have just re-written a moderately complex program (a Class) on the 
advice of Alan and Steven. The rewriting proved to be very useful.

The working program uses instances of the Class with User chosen 
parameters. The output data seems correct to me.

So I then began redoing all the tests. The first Methods tested gave OK.
But I have just started testing a new Method and I get a Universal error 
in my tests. It says that the output file is already present. These 
files (paths) are correctly deleted by the 'teardown' Method, when only 
the earlier portion of the program is tested. But are not deleted with 
the last method tested.

After searching I have found this unexpected output illustrated in the 
copy-paste below.

....
test


The type of the paths is    : <class 'tuple'>

The values of the paths are :


(   [ 
'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/',
 
'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/20181017D',
 
'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/20181017D/A_POCI_Input_Data',
.
.
.
.
        '/Users/sydney/AnacondaProjects/reproduction/Current_Version
/Results/20181017D/B_Cycle_Zero/Text_Files',
.
.
.
 
'/Users/sydney/AnacondaProjects/reproduction/Current_Version/Results/20181017D/C_Final_Results/Plots/Population_Data/Ratios'],
     '/Users/sydney/.Trash/20181017D/B_Cycle_Zero/Text_Files')

....

There are two items that are 'wrong' in this output.

1. The property 'paths' is defined in the program as a list and the 
items are added using paths.append(), yet the test says that when tested 
it is a tuple.
2. The tuple arises by the addition of the last entry in the file, AFTER 
the closing bracket of the list which is the first item in the tuple.

When I test the length of 'paths' I get a value of 2!

I apologise for the lengthy explanation, but I am at a loss.

I have looked for an error that might have added an item as a + and I 
find nothing.
The character of the final item is also puzzling to me.

I would much appreciate any guidance as to how I should search for the 
fault or error.

Sydney






_________




More information about the Tutor mailing list