Python as a scripting language. Alternative to bash script?
Jorgen Grahn
grahn+nntp at snipabacken.se
Tue Jun 29 05:06:24 EDT 2010
On Mon, 2010-06-28, John Nagle wrote:
> On 6/28/2010 7:58 AM, Benjamin Kaplan wrote:
>> How does a program return anything other than an exit code?
>
> Ah, yes, the second biggest design mistake in UNIX.
>
> Programs have "argv" and "argc", plus environment variables,
> going in. So, going in, there are essentially subroutine parameters.
> But all that comes back is an exit code. They should have had
> something similar coming back, with arguments to "exit()" returning
> the results. Then the "many small intercommunicating programs"
> concept would have worked much better.
Like others said, you have standard output. sys.stdout for data,
sys.stderr for human-readable errors and warnings, and the exit code
for machine-readable errors.
> C was like that once. In the 1970s, all you could return was
> an "int" or a "float". But that got fixed.
Huh? The C we have today cannot return a float, and not even a full int.
0 and 1 work, small integers up to 255 are likely to work, but beyond
that common systems (Unix) will chop off the high bits.
/Jorgen
--
// Jorgen Grahn <grahn@ Oo o. . .
\X/ snipabacken.se> O o .
More information about the Python-list
mailing list