Python Newbie

MRAB python at mrabarnett.plus.com
Sun Feb 24 01:11:45 CET 2013


On 2013-02-23 23:18, Chris Angelico wrote:
> On Sun, Feb 24, 2013 at 9:52 AM, Michael Torrie <torriem at gmail.com> wrote:
>> On 02/23/2013 02:38 PM, Chris Angelico wrote:
>>> On Sun, Feb 24, 2013 at 5:29 AM, Dennis Lee Bieber
>>> <wlfraed at ix.netcom.com> wrote:
>>>>         Error codes under DEC VAX/VMS used odd integers for
>>>> "success/information" and even integers for "warning/error" (been too
>>>> many years, I think positive integers were success/warning, negative
>>>> integers were information/error; I could also be wrong on which set were
>>>> even... if 0 were no-info/success then odd were errors and even were
>>>> success)).
>>>
>>> Sounds like IBM DB2 and sqlca.sqlcode - 0 for success, <0 for error,
>>>> 0 for warning (or in some cases "status" - an SQLCODE of 100 means
>>> "end of result set", which isn't exactly an error but you can't fetch
>>> any more from it; it's akin to Python raising StopIteration to
>>> terminate a for loop).
>>
>> All apps that return an error code to the operating system return 0 for
>> success, any other value for error.  All command-line utilities work
>> this way, all shells, etc.  Even Windows command-line apps work this way
>> (errorlevel is what they call it).
>
> Yep, the 0 = success part is pretty much universal (it's been said
> that the cause of the downfall of the Roman empire was that, lacking
> zero, they were unable to succeed at anything), but the notion of
> negative for errors and positive for warnings isn't as clear;
> errorlevels and Unix return codes are positive-only.
>
...although some C functions return a negative error code because a
non-negative value is the number of characters written.



More information about the Python-list mailing list