En Mon, 02 Mar 2009 13:09:05 -0200, Luis Zarrabeitia <ky...@uh.cu> escribió:
Quoting MRAB <goo...@mrabarnett.plus.com>:
Steven D'Aprano wrote:
>
You might want to specify an output folder (and the data might be binary
too):

zf = zipfile.ZipFile('Archive.zip')
for name in zf.namelist():
     open(os.path.join(output_folder, name), 'wb').write(zf.read(name))


Question here... wouldn't you also need to create all the intermediate folders from "output_folder" to "output_folder/name" (assuming that 'name' has several
path parts in it)? Is there any elegant way to do it?

Perhaps it would be easier to grab a copy of the 2.6 sources. extract() and extractall() are not so complex, but "the devil is in the details"

(is there any way to make os.mkdir behave like mkdir -p?)

if not os.path.isdir(d):
  os.makedirs(d)

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to