Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #107608
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Grant Edwards <grant.b.edwards@gmail.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Writing different sections into a file |
| Date | Mon, 25 Apr 2016 14:44:37 +0000 (UTC) |
| Lines | 29 |
| Message-ID | <mailman.81.1461595506.32212.python-list@python.org> (permalink) |
| References | <ad6f9260-0c01-4246-9be5-84b1d2470255@googlegroups.com> <nflagl$bbk$2@ger.gmane.org> |
| X-Trace | news.uni-berlin.de IyBSw9V9DVrTgSQ1JaDd/QtnSgQKO8Y/q/8Rd1tQQpJw== |
| Return-Path | <python-python-list@m.gmane.org> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'append': 0.07; 'subject:file': 0.07; 'footer.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:qwest.net': 0.09; 'section,': 0.09; 'stringio': 0.09; 'subject:Writing': 0.09; 'subject:into': 0.09; 'sections': 0.13; 'section.': 0.15; 'files).': 0.16; 'first:': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'why,': 0.16; 'wrote:': 0.16; 'string': 0.17; 'body,': 0.22; 'file.': 0.22; '(or': 0.23; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'header,': 0.29; 'point': 0.33; 'file': 0.34; 'this?': 0.34; 'list': 0.34; 'next': 0.35; "isn't": 0.35; 'to:addr:python-list': 0.36; 'subject:: ': 0.37; 'received:org': 0.37; 'desired': 0.37; 'done.': 0.37; 'hi,': 0.38; 'end': 0.39; 'data': 0.39; 'to:addr:python.org': 0.40; 'different': 0.63; 'life': 0.67; 'best?': 0.84; 'edwards': 0.91 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | 67-130-15-94.dia.static.qwest.net |
| User-Agent | slrn/1.0.2 (Linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.22 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://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 | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| X-Mailman-Original-Message-ID | <nflagl$bbk$2@ger.gmane.org> |
| X-Mailman-Original-References | <ad6f9260-0c01-4246-9be5-84b1d2470255@googlegroups.com> |
| Xref | csiph.com comp.lang.python:107608 |
Show key headers only | View raw
On 2016-04-25, Palpandi <palpandi111@gmail.com> wrote:
> Hi,
>
> I need to write different sections into a file. At any point of
> time, content can be added to any section.
>
> I don't want keep each section into a temporary file. What is the
> better way to store the contents of each section and write them into
> a file at the end?
What makes you think a temporary file isn't best?
> What is the better datatype to achieve this?
When in doubt, try the simplest approach first:
Use a string (or byte-string if it's not text) for each of the header,
body, and footer. Append data to each as desired and then write them
out to a file when you're done.
If that's not workable, explain why, and we can tell you what to try
next (probably a stringio for each section, or a list of strings or
byte-strings for each section, or temporary files).
--
Grant Edwards grant.b.edwards Yow! Wait ... is this a FUN
at THING or the END of LIFE in
gmail.com Petticoat Junction??
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Writing different sections into a file Palpandi <palpandi111@gmail.com> - 2016-04-25 00:30 -0700 Re: Writing different sections into a file Peter Otten <__peter__@web.de> - 2016-04-25 10:48 +0200 Re: Writing different sections into a file harirammanohar@gmail.com - 2016-04-25 02:50 -0700 Re: Writing different sections into a file Karim <kliateni@gmail.com> - 2016-04-25 12:04 +0200 Re: Writing different sections into a file Grant Edwards <grant.b.edwards@gmail.com> - 2016-04-25 14:44 +0000 Re: Writing different sections into a file justin walters <walters.justin01@gmail.com> - 2016-04-25 08:00 -0700 Re: Writing different sections into a file Karim <kliateni@gmail.com> - 2016-04-25 17:12 +0200
csiph-web