Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #37477

Re: Any algorithm to preserve whitespaces?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.straub-nv.de!newsreader4.netcologne.de!news.netcologne.de!newsfeed.freenet.ag!news2.euro.net!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <sntshkmr60@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.002
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; '16,': 0.03; 'error:': 0.05; 'valueerror:': 0.07; 'script,': 0.09; 'throws': 0.09; 'unpack': 0.09; 'valueerror': 0.09; 'cc:addr:python-list': 0.10; 'subject:whitespaces': 0.16; 'input': 0.18; 'skip:" 30': 0.20; 'cc:2**0': 0.23; 'cc:no real name:2**0': 0.24; 'cc:addr:python.org': 0.25; 'header:In-Reply-To:1': 0.25; '(most': 0.27; 'right.': 0.27; 'message-id:@mail.gmail.com': 0.27; 'methods.': 0.29; 'file': 0.32; 'traceback': 0.33; 'received:google.com': 0.34; 'subject:?': 0.35; 'received:209.85': 0.35; 'something': 0.35; 'received:209': 0.37; 'subject:: ': 0.38; 'mean': 0.38; 'takes': 0.39; 'more': 0.63; 'subject:Any': 0.84
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:x-received:in-reply-to:references:date:message-id :subject:from:to:cc:content-type; bh=1jzYJxDxv2ToC103tFn/OoyEFtLZOFTZfg0QsbZjvxg=; b=IZ8UblZUs7zR41p78/YX3AgpQTHzO0bTGlQmfPs3hMXFvf+jgkTMgWVq4GpRz5LxQT PUfJMoTzDFMWX+qIiaJLpAs7ZsasHgcR2s3s+JR39e+mymKfSqDXi4b7STHpvypgBbgv 0tP4qvs8TNJzRegn5bmAzdrz0abA8dfhp1IsRYtmEaJZ3oJ+L9Nb2eztDLZVMcxQ8Zdd hJcAvpM71waQ8vBGxWfvxxUhM2WI0y/fPCzuS6zQTEwmoiTLzcYHDVPwn8M/DH6pVtT0 RvqH7uLZuSpSq3hHfoFDiBu2qOahxp1LnwDdEjNiHPU0IohyYN914S6zimB6iCc21jM9 rYnA==
MIME-Version 1.0
X-Received by 10.182.123.49 with SMTP id lx17mr1188005obb.63.1358953015147; Wed, 23 Jan 2013 06:56:55 -0800 (PST)
In-Reply-To <50FFBCC5.5020506@davea.name>
References <CAE7MaQZyvwOvD6ggMDZ4+b=r1PsKuYX+VZThEpKvxBbfJJCK3g@mail.gmail.com> <50FAEE23.5030107@lightbird.net> <CAE7MaQb2-qQXuAJ4jK6RB+fOPO0ZjK6_gEuigqP_FOn0=Sv29g@mail.gmail.com> <50FFBCC5.5020506@davea.name>
Date Wed, 23 Jan 2013 20:26:55 +0530
Subject Re: Any algorithm to preserve whitespaces?
From Santosh Kumar <sntshkmr60@gmail.com>
To Dave Angel <d@davea.name>
Content-Type text/plain; charset=UTF-8
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.900.1358953018.2939.python-list@python.org> (permalink)
Lines 18
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1358953018 news.xs4all.nl 6906 [2001:888:2000:d::a6]:40234
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:37477

Show key headers only | View raw


Yes, Peter got it right.

Now, how can I replace:

    script, givenfile = argv

with something better that takes argv[1] as input file as well as
reads input from stdin.

By input from stdin, I mean that currently when I do `cat foo.txt |
capitalizr` it throws a ValueError error:

    Traceback (most recent call last):
      File "/home/santosh/bin/capitalizr", line 16, in <module>
        script, givenfile = argv
    ValueError: need more than 1 value to unpack

I want both input methods.

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: Any algorithm to preserve whitespaces? Santosh Kumar <sntshkmr60@gmail.com> - 2013-01-23 20:26 +0530
  Re: Any algorithm to preserve whitespaces? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-01-24 11:49 +1100
    Re: Any algorithm to preserve whitespaces? Dave Angel <d@davea.name> - 2013-01-23 21:05 -0500

csiph-web