Re: 转发: How to exit program with custom code and custom message?

Lars Liedtke lal at solute.de
Mon Mar 13 10:16:34 EDT 2023


I totally understand your reasoning here, but in some way it follows the unix philosophy: Do only one thing, but do that good.

And exiting is something different from printing to STDOUT or STDERR. Yes sometimes you want to print something before exiting. But then you should do that explicitly and to the output you want and not implicitly rely on adfdtitional parameters of exit. Yes, not all functions work this way. But that does not mean they shouln't ;-)

Cheers

Lars

On 13.03.23 11:18, scruel tao wrote:

Chris:


It doesn't actually take a list of arguments; the square brackets


indicate that arg is optional here.

Oh, I see, it seems that I mistunderstood the document.



but for anything more complicated, just print and then exit.
It's worth noting, by the way, that sys.exit("error message") will
print that to STDERR, not to STDOUT, which mean that the equivalent
is:



Yes, I know, but don’t you think if `sys.exit` can take more parameters and have a default output channel selection strategy will be better?
Thanks.





Lars Liedtke
Software Entwickler

[Tel.]  +49 721 98993-
[Fax]   +49 721 98993-
[E-Mail]        lal at solute.de<mailto:lal at solute.de>


solute GmbH
Zeppelinstraße 15
76185 Karlsruhe
Germany


[Logo Solute]


Marken der solute GmbH | brands of solute GmbH
[Marken]
[Advertising Partner]

Geschäftsführer | Managing Director: Dr. Thilo Gans, Bernd Vermaaten
Webseite | www.solute.de <http://www.solute.de/>
Sitz | Registered Office: Karlsruhe
Registergericht | Register Court: Amtsgericht Mannheim
Registernummer | Register No.: HRB 110579
USt-ID | VAT ID: DE234663798



Informationen zum Datenschutz | Information about privacy policy
https://www.solute.de/ger/datenschutz/grundsaetze-der-datenverarbeitung.php





More information about the Python-list mailing list