Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
c59120ba
Commit
c59120ba
authored
Nov 14, 1996
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added os.remove()/unlink(), rmdir(), rename(), and [f]truncate().
parent
caa83c4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
Misc/FAQ
Misc/FAQ
+17
-0
No files found.
Misc/FAQ
View file @
c59120ba
...
...
@@ -179,6 +179,7 @@ Here's an overview of the questions per chapter:
4.39. Q. How to implement persistent objects in Python? (Persistent ==
automatically saved to and restored from disk.)
4.40. Q. I try to use __spam and I get an error about _SomeClassName__spam.
4.41. Q. How do I delete a file? And other file questions.
5. Extending Python
5.1. Q. Can I create my own functions in C?
...
...
@@ -1708,6 +1709,22 @@ A. Variables with double leading underscore are "mangled" to provide a
simple but effective way to define class private variables. See the
chapter "New in Release 1.4" in the Python Tutorial.
4.41. Q. How do I delete a file? And other file questions.
A. Use os.remove(filename) or os.unlink(filename); for documentation,
see the posix section of the library manual. They are the same,
unlink() is simply the Unix name for this function. In earlier
versions of Python, only os.unlink() was available.
To remove a directory, use os.rmdir(); use os.mkdir() to create one.
To rename a file, use os.rename().
To truncate a file, open it using f = open(filename, "w+"), and use
f.truncate(offset); offset defaults to the current seek position.
There's also os.ftruncate(fd, offset) for files opened with os.open()
-- for advanced Unix hacks only.
5. Extending Python
===================
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment