"print >> file" ok. What about "print > file" to truncate?
Stephen Hansen
stephen at cerebralmaelstrom.com
Mon Sep 4 01:12:23 EDT 2000
There's one problem with that -- the >> construct allows you to print out
to any file-like object, not just files. And for objects which aren't real
files, 'truncate' doesn't nessecarily make any sense. For instance, what
does it mean to 'truncate' stderr? Or a user-defined class that immediately
processes/sends data as soon as you write to it?
Besides, it would be _WAY_ too easy accidentely delete a file if that
were the case.
--Stephen
In article <39b2ae19.15922395 at news.accessone.com>, bokr at accessone.com
(Bengt Richter) wrote:
> IANAPP (I Am Not A Python Programmer), but truncating a file to zero
> length before writing can be useful. ">>" seems to mean "append"
> implicitly, so why not borrow the other redirection symbol? (No doubt
> you can accomplish this other ways, but not as concisely?)
>
> Just my 2 cent reaction, on seeing a python news article at
>
> http://www.oreillynet.com/pub/a/python/2000/08/30/pythonnews.html
>
> as I was randomly surfing thereabouts.
>
-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----== Over 80,000 Newsgroups - 16 Different Servers! =-----
More information about the Python-list
mailing list