473,388 Members | 1,375 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Documentation? file/open with tea

WryPyY's-

I've come across this file operation in others' code and have not seen any documentation for it: the use of "t" in the mode of file opening, such as:

f1=open(somefile, 'at')
f2=open(otherfile, 'rt')

[to be clear, I am talking about 't' tea, not '+' plus]

Is this merely another shorthand for a binary mode, or is there more going on with 't'?

Also, is this still a valid mode going forward, or has it been deprecated?
TIA
f=open("C:\somepath\All_domain_suffixes.txt",'rt')
f.read()

'\xa0.ac \xa0|\n\xa0.ad \xa0|\n\xa0.ae \xa0|\n\xa0.aero \xa0|\n\xa0.af \xa0|\n\xa0.ag \xa0|\n\xa0.ai \xa0|\n\xa0.al \xa0|\n\xa0.am \xa0|\n\xa0.an \xa0|\n\xa0.ao \xa0|\n\xa0.aq \xa0|\n\xa0.ar \xa0|
[... etc.]
Eric
:::::::::::::::::::::::::::::::::::
domainNot="@something.com"
domainIs=domainNot.replace("s","z")
ePrefix="".join([chr(ord(x)+1) for x in "do"])
mailMeAt=ePrefix+domainIs
:::::::::::::::::::::::::::::::::::
Jul 18 '05 #1
1 1687
On Sun, 19 Sep 2004 11:40:37 -0800, Eric Pederson wrote:
I've come across this file operation in others' code and have not seen any documentation for it:
the use of "t" in the mode of file opening, such as:

f1=open(somefile, 'at')
f2=open(otherfile, 'rt')

Is this merely another shorthand for a binary mode, or is there more going on with 't'?


No, but for 'text' resp. 'translated' mode
(though it comes from C/C++ on Windows).

Python's documentation on 'open()' (resp. 'file()') says, that the first
two arguments are the same as for C's stdio's 'fopen()'. And on Windows
you will often find that fopen() supports 't' as a mode extension (like
the well known 'b' for binary mode):

'b': open file in binary (untranslated) mode

't': open file in text (translated) mode;
(e.g. look for Ctrl-z as EOF marker)

Links:

Python's file() resp. open():
http://www.python.org/doc/2.3.4/lib/...built-in-funcs

(E.g.) Visual C++'s fopen():
http://msdn.microsoft.com/library/de...c_._wfopen.asp

HTH, Th.

Jul 18 '05 #2

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

Similar topics

1
by: Fouff | last post by:
Hello all. I have a small question concerning the functions open(...) and file(...) with python 2.4 In the online version of the documentation in the build-in functions (section 2.1...
8
by: Will Pittenger | last post by:
I have a Windows program C# .NET solution where when I update its XML documentation, some tags are not recognized and turned into the corresponding HTML. Those tags include <c>, <code>, <para>,...
5
by: kbutterly | last post by:
Good morning all, I have a weird problem with my VS 2005 Documentation. When I open the help file through Start -Visual Studion 2005 ->Visual Studio 2005 Documentation, I get what appears to be...
2
by: Nathan Sokalski | last post by:
I have tried downloading and installing the ASP.NET AJAX Documentation from http://ajax.asp.net/documentation/default.aspx?tabid=47 but it requires me to do the following: 1. Install SQL Server...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.