Re: [Tutor] Sum files' size

2011-07-29 Thread Susana Iraiis Delgado Rodriguez
Thank you to all of you! After I read your mails I started to modify my code, I applied Ramit suggestion and got the result I wanted: mport os file_list = [] folders = None for root, folders, files in os.walk('C:\\'): file_list.extend(os.path.join( root,fi) for fi in files if (fi.ends

Re: [Tutor] Sum files' size

2011-07-28 Thread Steven D'Aprano
Susana Iraiis Delgado Rodriguez wrote: I want to get the size of 3 files. I already completed this step. Then I need to sum the 3 results I got. In order to do it I have the next code: [...] #Finally I want to sum the 3 terms: total = kb+kb2+kb3 But the output I got is : 15.5KB108.0bytes169.0b

Re: [Tutor] Sum files' size

2011-07-28 Thread Prasad, Ramit
>kb = sizeof_fmt(s) >shx1 = os.path.getsize(shx) >kb2 = sizeof_fmt(shx1) > total = kb+kb2+kb3 Instead only retrieve the formatted output at the end. That way you will not have to worry about converting back from strings, nor have to worry about adding number with different units (e.g. 10KB + 10M

Re: [Tutor] Sum files' size

2011-07-28 Thread Alan Gauld
Susana Iraiis Delgado Rodriguez wrote: I want to get the size of 3 files. I already completed this step. Then I need to sum the 3 results I got. In order to do it I have the next code: import os file_list = [] folders = None for root, folders, files in os.walk('C:\\'): file_list.ext

[Tutor] Sum files' size

2011-07-28 Thread Susana Iraiis Delgado Rodriguez
I want to get the size of 3 files. I already completed this step. Then I need to sum the 3 results I got. In order to do it I have the next code: import os file_list = [] folders = None for root, folders, files in os.walk('C:\\'): file_list.extend(os.path.join(root,fi) for fi in files