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


Groups > comp.lang.python > #52601

Re: How to I do this in Python ?

From random832@fastmail.us
References <mailman.614.1376636762.1251.python-list@python.org> <roy-C7472E.07470816082013@news.panix.com>
Subject Re: How to I do this in Python ?
Date 2013-08-16 14:17 -0400
Newsgroups comp.lang.python
Message-ID <mailman.4.1376677027.23369.python-list@python.org> (permalink)

Show all headers | View raw


On Fri, Aug 16, 2013, at 7:47, Roy Smith wrote:
> There is no need to shell out to dd just to do this.  All dd is doing 
> for you is seeking to the offset you specify and closing the file.  You 
> can do that entirely in Python code.
> 
> http://docs.python.org/2.7/library/stdtypes.html#file.seek

*ahem*

http://docs.python.org/2.7/library/stdtypes.html#file.truncate

The dd recipe was written some time over a decade ago as the easiest way
to achieve this at a shell prompt (before the truncate tool was added to
coreutils), and no-one's ever thought twice about it.

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


Thread

How to I do this in Python ? Ganesh Pal <ganesh1pal@gmail.com> - 2013-08-16 11:51 +0530
  Re: How to I do this in Python ? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-08-16 10:59 +0000
    Re: How to I do this in Python ? Ganesh Pal <ganesh1pal@gmail.com> - 2013-08-18 22:36 +0530
      Re: How to I do this in Python ? Steven D'Aprano <steve@pearwood.info> - 2013-08-19 07:27 +0000
        Re: How to I do this in Python ? Ganesh Pal <ganesh1pal@gmail.com> - 2013-08-28 10:10 +0530
  Re: How to I do this in Python ? Roy Smith <roy@panix.com> - 2013-08-16 07:47 -0400
    Re: How to I do this in Python ? random832@fastmail.us - 2013-08-16 14:17 -0400

csiph-web