473,378 Members | 1,531 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,378 software developers and data experts.

EOFError not getting raised

I have been trying to do something like this:

f = open('someDocs.str', 'r')
try:
while True:
ln = f.readline()
except EOFError:
print 'reached eof'
f.close()
sys.exit(1)
However, EOFError is never raised. What am I missing?
Jul 19 '05 #1
2 1795
On Fri, 10 Jun 2005 06:49:51 +0000 (UTC), David Bear
<Da********@asu.edu> declaimed the following in comp.lang.python:
However, EOFError is never raised. What am I missing?
The Python Library Reference, perhaps?

-=-=-=-=-=-=-=- PLR
readline( [size])
Read one entire line from the file. A trailing newline character is kept
in the string2.11 (but may be absent when a file ends with an incomplete
line). If the size argument is present and non-negative, it is a maximum
byte count (including the trailing newline) and an incomplete line may
be returned. An empty string is returned only when EOF is encountered
immediately. Note: Unlike stdio's fgets(), the returned string contains
null characters ('\0') if they occurred in the input.
-=-=-=-=-=-=-=-

.readline() does NOT raise EOF.

f = open('someDocs.str', 'r')
while True:
ln = f.readline()
if not ln: break
print 'reached eof'
f.close()
sys.exit(1)

-- ================================================== ============ <
wl*****@ix.netcom.com | Wulfraed Dennis Lee Bieber KD6MOG <
wu******@dm.net | Bestiaria Support Staff <
================================================== ============ <
Home Page: <http://www.dm.net/~wulfraed/> <
Overflow Page: <http://wlfraed.home.netcom.com/> <

Jul 19 '05 #2
See http://docs.python.org/lib/module-exceptions.html: EOFError gets
raised when input() or raw_input() hit an EOF condition without reading
data.

Jul 19 '05 #3

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

Similar topics

2
by: Rex Eastbourne | last post by:
Hi, I'm executing a python script as a cron job. When I run it myself from the command line it works, but when cron executes it I get an EOFError: File "/home/rex/cronscript.py", line 6, in ?...
4
by: planetthoughtful | last post by:
Hi All, I have a relatively simple web user control I've included in a page that simply presents 3 drop down lists and a submit button, that I use as a date picker (ie one list for day, one for...
4
by: sloan | last post by:
I"m trying to figure out what concept I'm missing here, or if its not a good idea .. or what. Here is my example.. code is below. I have an employee class. It has an event that can be raised....
2
by: Dr. Pastor | last post by:
Python 2.5b3 on Windows XP. (exception EOFError Raised when one of the built-in functions (input() or raw_input()) hits an end-of-file condition (EOF) without reading any data.) For me,...
0
by: MikalE | last post by:
I’m using a third-party ActicveX component that has the following description for one of its events: They mean by this that LocationType is an array of VARIANTS (containing enumeration) When...
3
by: ronchese | last post by:
Hello. I wrote a Web Custom Control that have a property named SelectedValue. This SelectedValue property is set after the user clicks a LinkButton control, by its Click() event. I did some...
0
by: Rahul Babbar | last post by:
Hi, I am getting the error while trying to take a backup of the schema according to the backupschema.sql written at...
5
by: Rahul Babbar | last post by:
Hi, I am getting the error while trying to take a backup of the schema according to the backupschema.sql written at http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0602... ...
1
by: Jon Bowlas | last post by:
Hi All, I've written a little method to connect to an ftpserver which works well, however when I send a file using this ftp connection oddly I _sometimes_ get returned an EOFError from...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...
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...

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.