Silly question about ungzipping a file

Lemniscate d_blade8 at hotmail.com
Fri Sep 27 15:07:20 EDT 2002


Wow, thanks a bunch.  Let me just say that this did the trick with
flying colors.  Of course, now I have to go buy FL's book (my wife was
giving me grief but now I have an excellent argument in my cause). 
Thanks a bunch,
Lem


Alex Martelli <aleax at aleax.it> wrote in message news:<kSTk9.149109$ub2.3289741 at news1.tin.it>...
> Lemniscate wrote:
>         ...
> >>>> import gzip
> >>>> myFile = gzip.open('LL_tmpl.gz')
> >>>> file('output.txt', 'w').write(myFile.read())
> >>>> 
> > 
> > Now, is there any way to do this so that less memory is used?  I mean,
> 
> import shutil
> shutil.copyfileobj(myFile, open('output.txt', 'w'))
> 
> > 129MB.  I'm sure I'm just missing something simple, but why is that?
> 
> I think the reason you're missing this simple something is that you
> are not entirely familiar with Python's rich standard library -- a
> defect common to us all (I don't recall _every_ useful module either:-).
> 
> A partial help is /F's "Python Standard Library" (O'Reilly) -- it
> won't magically infuse you with knowledge of every such module, but
> by giving at least one example script for each module in the
> library (all in a remarkably concise 280 pages!) it makes it quite
> a bit more likely that more modules will stay in your subconscious
> memory.  Python's online reference, Beazley's New Riders book, my
> Nutshell when it comes (the delay ain't my fault THIS time - the
> complete, technically-revised draft is currently in the editor's
> hands!-), each give a different perspective on Python's standard
> library, and enhance the likelihood that you'll know where to find
> excellent code ripe for reuse.  Probably the best single piece of
> advice is the one in the Python online docs -- "sleep with the
> Library Reference under your pillow" (and use a thin pillow, so that
> the knowledge has an easier time filtering up into your brain:-).
> 
> 
> Alex



More information about the Python-list mailing list