473,406 Members | 2,707 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,406 software developers and data experts.

file open/read/name etc, not working

import os

print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
d.readline()

returns true in the shell but prints no text even though the document
contains text.

d.name returns nothing, d.name() raises an error.
Jun 27 '08 #1
4 860
On 15 Maj, 18:12, globalrev <skanem...@yahoo.sewrote:
import os

print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
d.readline()

returns true in the shell but prints no text even though the document
contains text.

d.name returns nothing, d.name() raises an error.
wow im an idiot. print...
Jun 27 '08 #2
On May 16, 2:12 am, globalrev <skanem...@yahoo.sewrote:
import os

print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
Two different paths again.
d.readline()
This reads one line and then does absolutely nothing with it. The
Python interactive shell prints the result of each expression, which
is a Good Thing. For Python to do the same when running a script would
be a Bad Thing.

readline and readlines are old hat; instead, iterate over the file
object, like this:

for line in d:
print line,
>
returns true in the shell but prints no text even though the document
contains text.

d.name returns nothing, d.name() raises an error.
d.name should return the name of the file; I suspect that you again
have done nothing with it. d.name() would raise an exception because
d.name is not a method, so you can't call it.

HTH,
John
Jun 27 '08 #3
>import os
>
print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
d.readline()

returns true in the shell but prints no text even though the document
contains text.

d.name returns nothing, d.name() raises an error.
--
http://mail.python.org/mailman/listinfo/python-list
Try...

import os

print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
for line in d:
print line
And I'm guessing that's a typo in flim.txt?

Cheers,

Drea
Jun 27 '08 #4
On 15 Maj, 18:33, "Andreas Tawn" <andreas.t...@ubisoft.comwrote:
import os
print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
d.readline()
returns true in the shell but prints no text even though the document
contains text.
d.name returns nothing, d.name() raises an error.
--
http://mail.python.org/mailman/listinfo/python-list

Try...

import os

print os.path.exists('C:/Python25/myPrograms/netflix/test.txt')
d=open('C:/Python25/myPrograms/netflix/flim.txt', 'r')
for line in d:
print line

And I'm guessing that's a typo in flim.txt?

Cheers,

Drea
nah no typos i figured this out
Jun 27 '08 #5

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

Similar topics

2
by: SL_McManus | last post by:
Hi All; I am fairly new to Perl. I have a file with close to 3000 lines that I would like to split out in a certain way. I would like to put the record type starting in column 1 for 2 spaces,...
18
by: Jen | last post by:
I'm using Microsoft's own VB.NET FTP Example: http://support.microsoft.com/default.aspx?scid=kb;en-us;832679 I can get the program to create directories, change directories, etc., but I can't...
0
grassh0pp3r
by: grassh0pp3r | last post by:
Hello, I'm trying to make a very simple comments page on my site using PHP and am having problems somewhere. I am very new to PHP. I was able to create one that works with comments appended, but...
9
by: flebber | last post by:
I was working at creating a simple program that would read the content of a playlist file( in this case *.k3b") and write it out . the compressed "*.k3b" file has two file and the one I was trying...
1
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.