473,569 Members | 2,472 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The format of filename

Where can I find documentation of what Python accepts as the
filename argument to the builtin function file?

As an example, I'm aware (through osmosis?) that I can use '/' as
a directory separator in filenames on both Unix and Dos. But
where is this documented?

--
Neil Cerutti
Oct 24 '06 #1
19 2337
Neil Cerutti wrote:
Where can I find documentation of what Python accepts as the
filename argument to the builtin function file?
Python will accept whatever the OS accepts.
As an example, I'm aware (through osmosis?) that I can use '/' as
a directory separator in filenames on both Unix and Dos. But
where is this documented?
It's documented in the OS's documentation. It can be queried with os.sep
and os.altsep.
Oct 24 '06 #2
Neil Cerutti wrote:
Where can I find documentation of what Python accepts as the
filename argument to the builtin function file?

As an example, I'm aware (through osmosis?) that I can use '/' as
a directory separator in filenames on both Unix and Dos. But
where is this documented?
in the documentation for your operating system. Python doesn't do
anything with the filenames.

</F>

Oct 24 '06 #3
On 2006-10-24, Leif K-Brooks <eu*****@ecritt ers.bizwrote:
Neil Cerutti wrote:
>As an example, I'm aware (through osmosis?) that I can use '/'
as a directory separator in filenames on both Unix and Dos.
But where is this documented?

It's documented in the OS's documentation. It can be queried
with os.sep and os.altsep.
Thanks. The contents of 6.1.6 Miscellanious System Information
seems to be what I'm looking for.

--
Neil Cerutti
I've had a wonderful evening, but this wasn't it. --Groucho Marx
Oct 24 '06 #4
On 2006-10-24, Fredrik Lundh <fr*****@python ware.comwrote:
Neil Cerutti wrote:
>Where can I find documentation of what Python accepts as the
filename argument to the builtin function file?

As an example, I'm aware (through osmosis?) that I can use '/' as
a directory separator in filenames on both Unix and Dos. But
where is this documented?

in the documentation for your operating system. Python doesn't
do anything with the filenames.
Is translation of '/' to '\\' a feature of Windows or Python?

--
Neil Cerutti
Oct 24 '06 #5
Neil Cerutti wrote:
Is translation of '/' to '\\' a feature of Windows or Python?
It's a feature of Windows, but it isn't a translation. Both slashes are
valid path separators on Windows; backslashes are just the canonical form.
Oct 24 '06 #6
On 2006-10-24, Neil Cerutti <ho*****@yahoo. comwrote:
Is translation of '/' to '\\' a feature of Windows or Python?
Well, *that* was easy to discover on my own. ;-)

Thanks for the pointers.

--
Neil Cerutti
Oct 24 '06 #7
Neil Cerutti wrote:
Is translation of '/' to '\\' a feature of Windows or Python?
Windows. Random MSDN link:

http://msdn2.microsoft.com/en-us/library/77859s1t.aspx

Win32 operating systems support both the backslash (\) and
the forward slash (/). /.../ (However, the Windows operating
system command shell, CMD.EXE, does not support the forward
slash in commands entered at the command prompt.)

for general file naming guidelines for Windows (including the shell), see:

http://msdn.microsoft.com/library/en...ing_a_file.asp

</F>

Oct 24 '06 #8
>As an example, I'm aware (through osmosis?) that I can use '/' as
>a directory separator in filenames on both Unix and Dos. But
where is this documented?

in the documentation for your operating system. Python doesn't do
anything with the filenames.
Windows seems to be (occasionally) doing the translation as /F
mentions:

C:\temppython
Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit
(Intel)] on win32
Type "help", "copyright" , "credits" or "license" for more
information.
>>for line in file('subdir/test.txt'):
.... print line.strip()
....
1
2
3
>>^Z
C:\tempREM try the same filename convention from dos prompt
C:\temptype subdir/test.txt
The syntax of the command is incorrect.
C:\tempREM try with quotes, just in case...
C:\temptype "subdir/test.txt"
The syntax of the command is incorrect.
C:\tempnotepad subdir/test.txt
C:\tempREM correctly opened the text file in notepad

Windows seems to doing the translation inconsistently (I know
that comes as a shock...)

-tkc

Oct 24 '06 #9
On 2006-10-24, Neil Cerutti <ho*****@yahoo. comwrote:
On 2006-10-24, Neil Cerutti <ho*****@yahoo. comwrote:
>Is translation of '/' to '\\' a feature of Windows or Python?

Well, *that* was easy to discover on my own. ;-)

Thanks for the pointers.
Some experimentation shows that Python does seem to provide
*some* translation. Windows lets me use '/' as a path separator,
but not as the name of the root of a partition name. But perhaps
this a peculiarity of the commands themselves, and not of Windows
path names in particular.

C:\PYTHON24>CD /
The syntax of the command is incorrect.

C:\PYTHON24>CD \
C:\>EDIT /PYTHON24/README
The syntax of the command is incorrect.

--
Neil Cerutti
The outreach committee has enlisted 25 visitors to make calls on
people who are not afflicted with any church. --Church Bulletin
Blooper
Oct 24 '06 #10

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

Similar topics

2
7415
by: Alexander Schmidt | last post by:
Hi, I am not very familiar with C++ programming, so before I do a dirty hack I ask for a more elegant solution (but only the usage of STL is allowed, no special libs). So I need to read a file in OFF format and store the values read in some file format, I suppose in arrays of floats or ints would be meaningful: My general idea:
5
2447
by: Jim McGivney | last post by:
In an aspx page I run the following C# code-behind: string filename = null; filename = txtUpload.PostedFile.FileName.Trim(); //save the file txtUpload.PostedFile.SaveAs(@"C:\home\sites\bobo.com\web\" + filename); I get the following error: The given path's format is not supported. Any suggestions as to the proper format for the path...
2
2934
by: Pat | last post by:
Here is my problem that I am having with a current project. I went and backed up all my hard drives to DVD's. After backing up the drives, I used a batch file to get all the file names from the disk to a text file for future reference. I now have over 60 huge text files and would like to place the information into either a database or an excel...
4
2429
by: Dave | last post by:
I am writing a C# app in which I need to enumerate the processes running on the PC. I have succesfully done this as follows (assuming the app is running on NT4, XP, 2000 or 2003): ManagementScope ms = new System.Management.ManagementScope("\\\\localhost\\root\\cimv2"); ObjectQuery oq = new System.Management.ObjectQuery("SELECT * FROM...
14
2365
by: Manish | last post by:
The project I am developing doesn't involves database. I want to parse the mailbox file (.mbx) and store the summary in the text file for fast retrieval and display of information in the Inbox page. The sugegsted format are as: #1 ID : Subject : To Address: From Address...etc...
4
3487
by: PengYu.UT | last post by:
Suppose I have a dos format text file. The following python code will print ^M at the end. I'm wondering how to print it in unix format. fh = open(options.filename) for line in fh.readlines() print line, Thanks, Peng
0
1608
eboyjr14
by: eboyjr14 | last post by:
I have this xml metacity thing, and it is giving off this error: The file format is invalid. <?xml version="1.0"?> <metacity_theme> <info> <name>Royale</name> <author>Devin Samarin</author> <copyright>Devin Samarin, 2007</copyright>
2
2124
by: Dhananjay | last post by:
Hi all , I have got problem when i am tring to exportGridview Data into Excel format. It is going into text format ,but what i want is if the field is number/currency then it should go into number/currency format itself .Data exported to excel are all exported as text. Export to excel should maintain the formatting like numbers and money...
4
2526
by: krishp | last post by:
Hi, I need to convert raw data recieved from a device through C#.Net socket to BMP format. For some reason the image conversion is not happening proparly and I can see only blur image . Following is the code : try { string receivedPath = "c:\\NEW\\";
5
3763
by: The Pipe | last post by:
Hello I have a table that I need to export to a .asc file format. I have had several attempts at getting this to work but with no luck. Basically the file would need to have every record displayed on a separate line - If you like a CrLF delimited file. The unfortunate thing is that the file is to be then imported into a third party piece of...
0
7618
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7926
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8138
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6287
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5514
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5223
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3657
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2117
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 we have to send another system
1
1228
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.