Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #43430

Re: shutil.copyfile is incomplete (truncated)

Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.02; 'syntax': 0.04; 'assign': 0.07; 'subject:skip:s 10': 0.07; 'string': 0.09; 'f.close()': 0.09; '4:25': 0.16; 'code?': 0.16; 'evaluating': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; "function's": 0.16; 'parentheses': 0.16; 'temp': 0.16; '(you': 0.16; 'wrote:': 0.18; 'file,': 0.19; 'command': 0.22; 'instance,': 0.24; '(or': 0.24; 'defined': 0.27; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'statement': 0.30; 'message-id:@mail.gmail.com': 0.30; 'file:': 0.31; 'operations.': 0.31; 'text': 0.33; 'fri,': 0.33; 'actual': 0.34; 'could': 0.34; 'subject: (': 0.35; 'received:209.85': 0.35; 'problem.': 0.35; 'received:209.85.220': 0.35; 'done.': 0.35; 'received:google.com': 0.35; 'object,': 0.36; 'method': 0.36; 'should': 0.36; 'received:209': 0.37; 'to:addr :python-list': 0.38; 'pm,': 0.38; '12,': 0.39; 'to:addr:python.org': 0.39; "you're": 0.61; 'name': 0.63; 'close': 0.67; "'with'": 0.84; '2013': 0.98
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:content-type; bh=aPsvnkYmk2AJ4ojLchMHPXflcWyIQL8juqJzusm5f7I=; b=cB2zN34SdaUgP8UEuJTEUxlebHcrR0ZJapx7dxdXFiyyCwWEhPbP75r2euvVUYCJyv SvpXqmMsYyu1LXY75473lTIYda6lIjCj3vi99GUCsHoGS2sUG59GceXb+qrGiU7dKwgm FfpK36n+3yybpX8qkwWLL9o+nzdLG269vJrOHUtLpLHEWHwDi4DtXJO4LXRH1GwJx9f3 V5iswFxtGQpl7Z70nCZ4l+mwbI1Q5lxK7wmzpI7WeuEhwXvbh8nqDkILQ6dfxrsigJIc gatWr5eErcSgFAOaAvqItwtGBjtt9A1Z/jtMYuW1uLbvcDSd20jULiY9hzYfrDxBpDg7 fTCQ==
MIME-Version 1.0
X-Received by 10.220.104.20 with SMTP id m20mr7464904vco.70.1365751940553; Fri, 12 Apr 2013 00:32:20 -0700 (PDT)
In-Reply-To <d457256e-a195-4c14-ac7f-0afb6b45dc15@googlegroups.com>
References <e8878747-fd9d-41d2-9ce1-096a65590f84@googlegroups.com> <asof5aFknkrU1@mid.individual.net> <5363f8ea-f2a6-4a08-a216-18c6666ba698@googlegroups.com> <asoiq9Flkh1U1@mid.individual.net> <d457256e-a195-4c14-ac7f-0afb6b45dc15@googlegroups.com>
Date Fri, 12 Apr 2013 17:32:20 +1000
Subject Re: shutil.copyfile is incomplete (truncated)
From Chris Angelico <rosuav@gmail.com>
To python-list@python.org
Content-Type text/plain; charset=ISO-8859-1
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.508.1365751943.3114.python-list@python.org> (permalink)
Lines 33
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1365751943 news.xs4all.nl 2583 [2001:888:2000:d::a6]:47396
X-Complaints-To abuse@xs4all.nl
Path csiph.com!usenet.pasdenom.info!news.franciliens.net!feed.ac-versailles.fr!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Xref csiph.com comp.lang.python:43430

Show key headers only | View raw


On Fri, Apr 12, 2013 at 4:25 PM, Rob Schneider <rmschne@gmail.com> wrote:
>
>> The close method is defined and flushing and closing a file, so
>>
>> it should not return until that's done.
>>
>>
>>
>> What command are you using to create the temp file?
>>
>>
>
> re command to write the file:
> f=open(fn,'w')
> ... then create HTML text in a string
> f.write(html)
> f.close

Hold it one moment... You're not actually calling close. The file's
still open. Is that a copy/paste problem, or is that your actual code?

In Python, a function call ALWAYS has parentheses after it. Evaluating
a function's name like that returns the function (or method) object,
which you then do nothing with. (You could assign it someplace, for
instance, and call it later.) Try adding empty parens:

f.close()

and see if that solves the problem. Alternatively, look into the
'with' statement and the block syntax that it can give to I/O
operations.

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 11:12 -0700
  Re: shutil.copyfile is incomplete (truncated) Neil Cerutti <neilc@norwich.edu> - 2013-04-11 18:53 +0000
    Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 12:07 -0700
      Re: shutil.copyfile is incomplete (truncated) Neil Cerutti <neilc@norwich.edu> - 2013-04-11 19:55 +0000
        Re: shutil.copyfile is incomplete (truncated) Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-12 00:06 +0000
          Re: shutil.copyfile is incomplete (truncated) Cameron Simpson <cs@zip.com.au> - 2013-04-12 11:15 +1000
          Re: shutil.copyfile is incomplete (truncated) Ned Deily <nad@acm.org> - 2013-04-11 18:33 -0700
            Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 23:32 -0700
              Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 23:53 -0700
                Re: shutil.copyfile is incomplete (truncated) Ned Deily <nad@acm.org> - 2013-04-12 00:53 -0700
              Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 23:53 -0700
              Re: shutil.copyfile is incomplete (truncated) Cameron Simpson <cs@zip.com.au> - 2013-04-12 18:26 +1000
                Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-12 02:18 -0700
                Re: shutil.copyfile is incomplete (truncated) Chris Angelico <rosuav@gmail.com> - 2013-04-12 19:22 +1000
                Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-12 05:07 -0700
                Re: shutil.copyfile is incomplete (truncated) Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-04-12 13:18 +0100
                Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-12 05:07 -0700
                Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-12 02:18 -0700
                Re: shutil.copyfile is incomplete (truncated) Roy Smith <roy@panix.com> - 2013-04-12 10:57 -0400
                Re: shutil.copyfile is incomplete (truncated) Roy Smith <roy@panix.com> - 2013-04-12 10:54 -0400
            Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 23:32 -0700
              Re: shutil.copyfile is incomplete (truncated) Roy Smith <roy@panix.com> - 2013-04-12 10:47 -0400
          Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 23:27 -0700
          Re: shutil.copyfile is incomplete (truncated) Roy Smith <roy@panix.com> - 2013-04-12 10:51 -0400
          Re: shutil.copyfile is incomplete (truncated) 88888 Dihedral <dihedral88888@googlemail.com> - 2013-04-12 08:49 -0700
          Re: shutil.copyfile is incomplete (truncated) Nobody <nobody@nowhere.com> - 2013-04-13 03:33 +0100
            Re: shutil.copyfile is incomplete (truncated) Chris Angelico <rosuav@gmail.com> - 2013-04-13 13:05 +1000
            [OT] Lying hard drives [was Re: shutil.copyfile is incomplete (truncated)] Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-04-13 03:17 +0000
              Re: [OT] Lying hard drives [was Re: shutil.copyfile is incomplete (truncated)] Chris Angelico <rosuav@gmail.com> - 2013-04-13 13:43 +1000
        Re: shutil.copyfile is incomplete (truncated) Rob Schneider <rmschne@gmail.com> - 2013-04-11 23:25 -0700
          Re: shutil.copyfile is incomplete (truncated) Chris Angelico <rosuav@gmail.com> - 2013-04-12 17:32 +1000
          Re: shutil.copyfile is incomplete (truncated) Terry Jan Reedy <tjreedy@udel.edu> - 2013-04-12 10:48 -0400

csiph-web