Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #100761
| Path | csiph.com!fu-berlin.de!uni-berlin.de!not-for-mail |
|---|---|
| From | Ben Finney <ben+python@benfinney.id.au> |
| Newsgroups | comp.lang.python |
| Subject | Re: Why doesn't os.remove work on directories? |
| Date | Wed, 23 Dec 2015 16:02:55 +1100 |
| Lines | 33 |
| Message-ID | <mailman.78.1450846996.2237.python-list@python.org> (permalink) |
| References | <m21tadhjoo.fsf@fastmail.com> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=utf-8 |
| Content-Transfer-Encoding | 8bit |
| X-Trace | news.uni-berlin.de ts0/BB4bA02ratIk0ExVPQmdZNHPtqw0/2qZm7hLNqJQ== |
| Cancel-Lock | sha1:+HTvEYTsjJLg0lSu/thONH0bD08= |
| 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.006 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'raises': 0.07; 'implemented,': 0.09; 'oserror': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:Why': 0.09; 'python': 0.10; 'argument)': 0.16; 'behaviour.': 0.16; 'decision?': 0.16; 'posix': 0.16; 'rationale': 0.16; 'received:80.91.229.3': 0.16; 'received:io': 0.16; 'received:plane.gmane.org': 0.16; 'received:psf.io': 0.16; 'surprising': 0.16; 'documented': 0.18; 'implementing': 0.18; 'amounts': 0.22; 'function,': 0.22; 'implemented': 0.24; 'header:User-Agent:1': 0.26; 'header:X -Complaints-To:1': 0.26; 'function': 0.28; 'this.': 0.28; 'behaviour': 0.29; 'code': 0.30; 'anyone': 0.32; 'raising': 0.33; 'instead': 0.36; 'there': 0.36; 'subject:work': 0.36; 'to:addr :python-list': 0.36; 'subject:?': 0.36; 'subject:: ': 0.37; 'expect': 0.37; 'received:org': 0.37; 'no,': 0.38; 'files': 0.38; 'why': 0.39; 'to:addr:python.org': 0.40; 'leading': 0.61; 'our': 0.64; 'concerns': 0.66; 'skip:\xe2 10': 0.70; '8bit%:40': 0.72; 'contrary': 0.72; '8bit%:45': 0.84; '_o__)': 0.84; 'necessity': 0.84; 'received:125': 0.84; '\xe2\x80\x9cthis': 0.84 |
| X-Injected-Via-Gmane | http://gmane.org/ |
| X-Gmane-NNTP-Posting-Host | jigong.madmonks.org |
| X-Public-Key-ID | 0xAC128405 |
| X-Public-Key-Fingerprint | 517C F14B B2F3 98B0 CB35 4855 B8B2 4C06 AC12 8405 |
| X-Public-Key-URL | http://www.benfinney.id.au/contact/bfinney-pubkey.asc |
| X-Post-From | Ben Finney <bignose+hates-spam@benfinney.id.au> |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/24.4 (gnu/linux) |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.20+ |
| 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> |
| Xref | csiph.com comp.lang.python:100761 |
Show key headers only | View raw
Random832 <random832@fastmail.com> writes:
> This is surprising to anyone accustomed to the POSIX C remove
> function, which can remove either files or directories. Is there
> any known rationale for this decision?
No, I don't know a rationale for implementing it this way.
I expect the explanation will be “mere historical accident”. My
evidence-free reconstruction of the events leading to the current state
of play:
1. ‘os.unlink’ implemented, using C ‘unlink(3)’. Because ‘unlink(2)’
on a directory will cause an error, Python raises OSError for this.
2. ‘os.remove’ implemented; “This is identical to the unlink() function
documented below.”.
3. Backward compatibility concerns (existing code might depend on
‘os.remove’ raising OSError for a directory argument) justify
keeping the existing behaviour.
What you're looking for amounts to “why was ‘os.remove’ implemented as a
synonym of ‘unlink(3)’ instead of ‘remove(3)’?”.
I don't know why that behaviour was chosen, and I consider it a wart.
--
\ “… no testimony can be admitted which is contrary to reason; |
`\ reason is founded on the evidence of our senses.” —Percy Bysshe |
_o__) Shelley, _The Necessity of Atheism_, 1811 |
Ben Finney
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
Re: Why doesn't os.remove work on directories? Ben Finney <ben+python@benfinney.id.au> - 2015-12-23 16:02 +1100
csiph-web