473,480 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Not clear on what documentation means here [pxlpluker]

Not clear on what documentation means here.
What exactly does the underlined text mean. w & a obviously mean you are
going to update the file.
So what does the + mean on w+ & a+ mean?
Also please could someone explain w+ truncating the file.
I may just be dense so please be patient :)

-------------------------------------------------------------------------
[Copy from python 2.3.3 help file]
file( filename [, mode [, bufsize ] ] )

Return a new file object (described earlier under Built-in Types). The
first two arguments are the same as for stdio's fopen(): filename is the
file name to be opened, mode indicates how the file is to be opened: 'r'
for reading, 'w' for writing (truncating an existing file), and 'a'
opens it for appending (which on some Unix systems means that all writes
append to the end of the file, regardless of the current seek position).

Modes 'r+', 'w+' and 'a+' open the file for updating (note that 'w+'
truncates the file). Append 'b' to the mode to open the file in binary
mode, on systems that differentiate between binary and text files (else
it is ignored). If the file cannot be opened, IOError is raised.
Jul 18 '05 #1
1 1736
pxlpluker wrote:
So what does the + mean on w+ & a+ mean? This means that you can write to the file, seek to a different position and
then read from the file without reopening.
Also please could someone explain w+ truncating the file.

This means that the file gets truncated.
If you open the file with w+ and write 10 bytes, the resulting file will
contain 10 bytes. If you open it with r+ and write 10 bytes, the resulting
file will contain the bytes you have just written and then bytes [10:] of
the original file.

Daniel

Jul 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2767
by: Peter | last post by:
I am just trying to learn python, to use for some fairly basic command line utilities which will run in either Windows/DOS or Linux. I cannot find a platform neutral way of manipulating the screen....
25
3049
by: Nitin Bhardwaj | last post by:
Well, i'm a relatively new into C( strictly speaking : well i'm a student and have been doing & studying C programming for the last 4 years).....and also a regular reader of "comp.lang.c" I...
22
4198
by: mp | last post by:
i have a python program which attempts to call 'cls' but fails: sh: line 1: cls: command not found i tried creating an alias from cls to clear in .profile, .cshrc, and /etc/profile, but none...
3
5716
by: walter | last post by:
Hi , I thought it's simple ,but end up come here for help(as lots of other times). --I have several HttpModule added in the root thru web.config, but I want to remove some and add some new ones in...
16
13502
by: Brian D | last post by:
I have a multiple select list that is created dynamically based on a previous selection on an asp page. The first thing I do is to clear the curent option list by ...
98
4482
by: tjb | last post by:
I often see code like this: /// <summary> /// Removes a node. /// </summary> /// <param name="node">The node to remove.</param> public void RemoveNode(Node node) { <...> }
4
6738
by: matt | last post by:
hello, so from time to time i have to write code to send a file or a stream back to the end user. in my mini library i have code to do so. however, some of the Response object properties arent...
2
2948
by: Zytan | last post by:
I know that WebRequest.GetResponse can throw WebException from internet tutorials. However in the MSDN docs: http://msdn2.microsoft.com/en-us/library/system.net.webrequest.getresponse.aspx It...
9
3733
by: Jess | last post by:
Hello, I tried to clear a vector "v" using "v.clear()". If "v" contains those objects that are non-built-in (e.g. string), then "clear()" can indeed remove all contents. However, if "v"...
0
6911
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7050
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
6966
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5344
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4488
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2999
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1303
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
564
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
185
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.