No file from stdin
aspineux
aspineux at gmail.com
Thu May 24 13:08:16 EDT 2007
On 24 mai, 18:48, Tartifola <tartif... at gmail.com> wrote:
> Hi,
> suppose a script of python is waiting for a file from the stdin and none
> is given. How can I make the script to stop and, for example, print an
> error message?
>
> Sorry for the n00b question and thanks
import sys
import os.path
if len(sys.argv)<2:
print >>sys.stderr, 'Usage: %s filename' %
(os.path.basename(sys.argv[0]),)
sys.exit(1)
print 'Your filename is %s' % (sys.argv[1],)
More information about the Python-list
mailing list