Deutsch   English   Français   Italiano  
<v4sphm$1h0cm$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!feed.opticnetworks.net!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Mark Bourne <nntp.mbourne@spamgourmet.com>
Newsgroups: comp.lang.c
Subject: Re: Baby X is bor nagain
Date: Tue, 18 Jun 2024 21:09:25 +0100
Organization: A noiseless patient Spider
Lines: 29
Message-ID: <v4sphm$1h0cm$1@dont-email.me>
References: <v494f9$von8$1@dont-email.me>
 <v49seg$14cva$1@raubtier-asyl.eternal-september.org>
 <v49t6f$14i1o$1@dont-email.me>
 <v4bcbj$1gqlo$1@raubtier-asyl.eternal-september.org>
 <v4bh56$1hibd$1@dont-email.me> <v4c0mg$1kjmk$1@dont-email.me>
 <v4c8s4$1lki1$4@dont-email.me> <20240613002933.000075c5@yahoo.com>
 <v4emki$28d1b$1@dont-email.me> <20240613174354.00005498@yahoo.com>
 <v4okn9$flpo$2@dont-email.me> <20240617002924.597@kylheku.com>
 <v4pddb$m5th$1@dont-email.me> <20240618115650.00006e3f@yahoo.com>
 <v4rv0o$1b7h1$1@dont-email.me> <v4s5lm$1ctk6$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 18 Jun 2024 22:09:27 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="f6dfeab3d9e88a3420799621ce1dfd5f";
	logging-data="1606038"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX18asr6gwcofTnDCuCkzpEl1"
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 SeaMonkey/2.53.18.2
Cancel-Lock: sha1:QFyndDc/1TC7+c3J6vKlLslj2Jk=
In-Reply-To: <v4s5lm$1ctk6$1@dont-email.me>
Bytes: 2525

Malcolm McLean wrote:
> On 18/06/2024 13:36, David Brown wrote:
>> #!/usr/bin/python3
>> import sys
>>
>> if len(sys.argv) < 2 :
>>      print("Usage: sums.py <input-file>")
>>      sys.exit(1)
>>
>> data = list(map(int, open(sys.argv[1], "r").read().split()))
>> n = len(data)
>> s = sum(data)
>> print("Count: %i, sum %i, average %i" % (n, s, s // n))
>>
>>
>>
> And here's a simple task for you. Our filesystem uses a new technology 
> and is a bit dicey. Occasionally you will get a read error. Can you 
> modify the python to print out that a read error has occurred?

No modification required ;)  A read error will raise an exception; 
unhandled exceptions are printed to stderr along with a stack trace, and 
the program terminates with a failure status.

If you don't want the stack trace, you can handle the exception to just 
print a message and exit, but this is comp.lang.c, not comp.lang.python.

-- 
Mark.