gerrit at nl.linux.org
Thu Oct 9 16:14:03 CEST 2003
Ivan Voras wrote:
> In a code such as:
> if len(sys.argv) < 2:
> print "I need arguments!"
> Is sys.exit() really a good choice? Is there something more elegant? (I
> tried return but it is valid only in a function)
An alternative that I often choose is:
raise SystemExit("I need arguments!")
This is the same in one line, and I think it is more elegant, because it
is higher-level: you are not using the low-level interface of error codes,
a non-programmer may not understand what '1' means, usually it means success
so that can be very confusing. I prefer raise SystemExit.
30. If a chieftain or a man leave his house, garden, and field and
hires it out, and some one else takes possession of his house, garden, and
field and uses it for three years: if the first owner return and claims
his house, garden, and field, it shall not be given to him, but he who has
taken possession of it and used it shall continue to use it.
-- 1780 BC, Hammurabi, Code of Law
Asperger Syndroom - een persoonlijke benadering:
Kom in verzet tegen dit kabinet:
More information about the Python-list