[Tutor] Python program design

Tiger12506 keridee at jayco.net
Tue Jul 24 20:34:54 CEST 2007

>> The line should be
>> s = getsize(join(root, name))
>> which will print the file size for each "name in files"
> I got it a bit later. It didn't like me trying to apply it in a print
> statement but if I assigned it first and the printed it, no issue.

This should give you no problem ~
print getsize(join(root, name))

If it does, copy/paste the error message

>> You may wish to build a dict inside your dict.
>> {(discID, discLbl): {'dir': '...',
>>                                  'filename': '...",
>> etc.
> That was my thinking also. I just don't know enough about databases to 
> know
> if I should shove the data raw into the DB or do some sorting first.

No matter what DB you use, whether a high performance DB like SQL or just 
pickle to write the dict to a file as is, you will want to keep the 
structure of the dict
similar to how you will use it in your program. At least I would. Perhaps 
some will
say that you want the dict structured so that feeding it into a DB engine is 
seamless (which depending on what structures the DB is capable of storing, 
be lists or dicts, etc.) You will have to decide which is easiest for you.

>> I don't know how you want to use it, but keeping the root directory is 
>> not
>> very useful. If you ever want to transfer your files to another computer
> If I were cataloging hard drives I would tend to agree.  But this is for
> removable media and backups so "anything goes",

EXACTLY! Anything goes. It is *very* possible for the drive letter of
removeable media to change between plug - ins. For example, I have to
USB flash drives that i plug in. They are assigned the first drive letter
available, in the order that they appear. The next time, I plug the second
flash drive in *first*, it is assigned the first drive letter this time!
Keeping the root directory in this situation would be useless! You would
be trying to access the files on the wrong flash drive!
IF you were going to use it for hard drives, I would keep track of the root
directory, but for removeable media, *forget it* and use the drive ID, disc 
because they are more stable!


More information about the Tutor mailing list