Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.glorb.com!newsfeed.xs4all.nl!newsfeed8.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.006 X-Spam-Evidence: '*H*': 0.99; '*S*': 0.00; 'see.': 0.07; 'subject:file': 0.07; 'wednesday,': 0.07; 'here?': 0.09; 'issue?': 0.09; 'subject:Posting': 0.09; 'python': 0.11; 'big,': 0.16; 'example?': 0.16; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'guess.': 0.16; 'inclined': 0.16; 'iteration': 0.16; 'subject:image': 0.16; 'subject:server': 0.16; 'sure.': 0.16; 'wrote:': 0.16; 'examples': 0.18; 'fix': 0.21; '2015': 0.23; 'header:In-Reply-To:1': 0.24; 'paul': 0.24; 'header:User-Agent:1': 0.26; 'chris': 0.26; 'plain': 0.27; "i'm": 0.29; 'once.': 0.29; 'really,': 0.29; "i'd": 0.31; 'know.': 0.34; 'subject:?': 0.34; 'file': 0.34; 'message-id:@gmail.com': 0.35; 'could': 0.35; 'to:addr:python-list': 0.35; 'text.': 0.35; "isn't": 0.35; 'too': 0.36; 'there': 0.36; 'data.': 0.36; 'subject:: ': 0.37; 'instead': 0.38; 'received:org': 0.38; 'pm,': 0.39; 'to:addr:python.org': 0.39; 'received:192': 0.39; 'sure': 0.40; 'your': 0.60; 'avoid': 0.61; 'details': 0.63; 'charset:windows-1252': 0.65; 'situation': 0.67; 'blob': 0.84; 'chrisa': 0.84; 'utc-4,': 0.84; 'write()': 0.91 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Wed, 17 Jun 2015 19:10:18 -0600 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: python-list@python.org Subject: Re: Posting gzip'd image file - server says Malformed Upload? References: <59756062-6632-46b4-a92c-aa3a260718a7@googlegroups.com> <0dd32144-8969-4e15-9e78-4c9698fb9d8c@googlegroups.com> In-Reply-To: <0dd32144-8969-4e15-9e78-4c9698fb9d8c@googlegroups.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 19 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1434589824 news.xs4all.nl 2886 [2001:888:2000:d::a6]:48637 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:92799 On 06/17/2015 06:45 PM, Paul Hubert wrote: > On Wednesday, June 17, 2015 at 8:24:17 PM UTC-4, Chris Angelico wrote: > >> Are you sure you want iteration and writelines() here? I would be >> inclined to avoid those for any situation that isn't plain text. If >> the file isn't too big, I'd just read it all in a single blob and then >> write it all out at once. >> >> ChrisA > > Do you think that would fix my issue? I recommend you try it and see. That's the only way to know. We don't know any details of your program or situation really, so we can only guess. > Could you give me an example? Instead of writelines(), just write() the data. There are examples in the official python docs I'm sure.