I am using Python 3.6.2 in a Conda virtual environment, on Linux Ubuntu 18.04.
I have tried several ways to list both the files and directories of a particular path but I every method I try seems to only list the files in a directory, not the files and directories.
My code contains
directory_contents = os.listdir(run_directory)
print(directory_contents)
which shows only
['170224-ARC122-1-uM-Cis-S1-subsample_R1_001.fastq.gz', '170224-ARC122-1-uM-Cis-S1-subsample_R2_001.fastq.gz']
If I call a break before the listdir command, and then step through the listdir command the variable is filled with the correct contents
ipdb.set_trace()
print(directory_contents)
directory_contents = os.listdir(run_directory)
print(directory_contents)
*** NameError: name 'directory_contents' is not defined
['170224-ARC122-1-uM-Cis-S1-subsample_R1_001.fastq.gz', 'bw', 'Stats', 'bwChrM', 'bg', '170224-ARC122-1-uM-Cis-S1-subsample_R2_001.fastq.gz', 'bgChrM', 'Log']
Calling the break after the listdir command
directory_contents = os.listdir(run_directory)
ipdb.set_trace()
print(directory_contents)
gives
['170313-ARC122-no-Cis-S5-subsample_R2_001.fastq.gz', '170313-ARC122-no-Cis-S5-subsample_R1_001.fastq.gz']
What is it that I am not understanding or what extra keyword/argument have I overlooked ? Why am I getting different results depending on if I break before the command or afterwards?
The apparent simplicity of this seems hardly worth posing as a question but I have run out of solutions.