donn at drizzle.com
Fri Oct 10 05:51:50 CEST 2003
Quoth "Ivan Voras" <ivoras at fer.hr>:
| 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)
Your question has already been answered many times over, so I will
instead note something about the above that is rather common but
wrong. "print" writes to sys.stdout (unless instructed otherwise),
and in the present case this output should certainly go to sys.stderr.
The easiest way to do that in recent versions of python (2.0 and
later) is "print >> sys.stderr".
Donn Cave, donn at drizzle.com
More information about the Python-list