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


Groups > comp.lang.python > #19020

Re: Problem while doing a cat on a tabbed file with pexpect

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder1.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <cameron@cskk.homeip.net>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.005
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; '"c"': 0.07; 'received:edu.au': 0.07; 'subject:while': 0.07; 'tab': 0.07; 'python': 0.08; 'subject:Problem': 0.09; "hasn't": 0.13; 'subject:file': 0.13; 'cc:addr:python-list': 0.15; 'this:': 0.15; "'r').read()": 0.16; 'from:addr:cs': 0.16; 'from:addr:zip.com.au': 0.16; 'from:name:cameron simpson': 0.16; 'message- id:@cskk.homeip.net': 0.16; 'officer.': 0.16; 'received:202.125.174': 0.16; 'received:202.125.174.133': 0.16; 'received:boardofstudies.nsw.edu.au': 0.16; 'received:cskk.homeip.net': 0.16; 'received:harvey.boardofstudies.nsw.edu.au': 0.16; 'received:homeip.net': 0.16; 'received:nsw.edu.au': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'wrote:': 0.16; 'bytes': 0.18; 'jan': 0.19; 'cheers,': 0.20; 'cc:no real name:2**0': 0.21; 'header:In-Reply-To:1': 0.22; 'indentation': 0.23; 'cc:2**0': 0.25; 'guess': 0.25; 'mine': 0.28; 'explicit': 0.28; 'print': 0.29; 'cc:addr:python.org': 0.29; 'separated': 0.30; 'sun,': 0.30; 'does': 0.32; 'actual': 0.32; 'header:User-Agent:1': 0.33; 'character': 0.34; 'file.': 0.34; 'all.': 0.34; '2.4': 0.34; 'solaris': 0.34; 'thank': 0.35; 'file': 0.35; 'received:au': 0.36; 'post': 0.36; 'charset:us-ascii': 0.36; 'two': 0.37; 'but': 0.37; 'using': 0.37; 'configured': 0.38; 'steven': 0.38; 'some': 0.38; 'created': 0.38; 'subject:with': 0.38; 'think': 0.38; 'clearly': 0.39; 'called': 0.39; 'subject:: ': 0.39; 'one,': 0.40; 'type': 0.60; 'more': 0.61; 'your': 0.61; 'you.': 0.64; 'here.': 0.64; 'alternative': 0.65; 'received:202': 0.65; 'show': 0.67; 'ali': 0.67; 'special': 0.67; 'spaces': 0.73; 'cameron': 0.77; 'place?': 0.84; 'saqib': 0.84; 'size?': 0.84; 'finger': 0.91; 'letters,': 0.91
Date Mon, 16 Jan 2012 10:40:08 +1100
From Cameron Simpson <cs@zip.com.au>
To Steven D'Aprano <steve+comp.lang.python@pearwood.info>
Subject Re: Problem while doing a cat on a tabbed file with pexpect
MIME-Version 1.0
Content-Type text/plain; charset=us-ascii
Content-Disposition inline
In-Reply-To <4f135b65$0$29987$c3e8da3$5496439d@news.astraweb.com>
User-Agent Mutt/1.5.21 (2010-09-15)
References <4f135b65$0$29987$c3e8da3$5496439d@news.astraweb.com>
Cc python-list@python.org
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
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.4781.1326670827.27778.python-list@python.org> (permalink)
Lines 49
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1326670827 news.xs4all.nl 6983 [2001:888:2000:d::a6]:35732
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:19020

Show key headers only | View raw


On 15Jan2012 23:04, Steven D'Aprano <steve+comp.lang.python@pearwood.info> wrote:
| On Sun, 15 Jan 2012 09:51:44 -0800, Saqib Ali wrote:
| > I am using Solaris 10, python 2.6.2, pexpect 2.4
| > 
| > I create a file called me.txt which contains the letters "A", "B", "C"
| > on the same line separated by tabs.
| [...]
| > Now, clearly the file contains tabs.
| 
| That is not clear at all. How do you know it contains tabs? How was the 
| file created in the first place?
| 
| Try this:
| 
| text = open('me.txt', 'r').read()
| print '\t' in text
| 
| My guess is that it will print False and that the file does not contain 
| tabs. Check your editor used to create the file.

I was going to post an alternative theory but on more thought I think
Steven is right here.

What does:

  od -c me.txt

show you? TABs or multiple spaces?

What does:

  ls -ld me.txt

tell you about the file size? Is it 6 bytes long (three letters, two
TABs, one newline)?

Steven hasn't been explicit about it, but some editors will write spaces when
you type a TAB. I have configured mine to do so - it makes indentation more
reliable for others. If I really need a TAB character I have a special
finger contortion to get one, but the actual need is rare.

So first check that the file really does contain TABs.

Cheers,
-- 
Cameron Simpson <cs@zip.com.au> DoD#743
http://www.cskk.ezoshosting.com/cs/

Yes Officer, yes Officer, I will Officer. Thank you.

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


Thread

Problem while doing a cat on a tabbed file with pexpect Saqib Ali <saqib.ali.75@gmail.com> - 2012-01-15 09:51 -0800
  Re: Problem while doing a cat on a tabbed file with pexpect Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-15 14:24 -0500
    Re: Problem while doing a cat on a tabbed file with pexpect Saqib Ali <saqib.ali.75@gmail.com> - 2012-01-15 16:11 -0800
      Re: Problem while doing a cat on a tabbed file with pexpect Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2012-01-15 22:35 -0500
      Re: Problem while doing a cat on a tabbed file with pexpect Michael Torrie <torriem@gmail.com> - 2012-01-15 20:47 -0700
  Re: Problem while doing a cat on a tabbed file with pexpect Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-15 23:04 +0000
    Re: Problem while doing a cat on a tabbed file with pexpect Cameron Simpson <cs@zip.com.au> - 2012-01-16 10:40 +1100
      Re: Problem while doing a cat on a tabbed file with pexpect Saqib Ali <saqib.ali.75@gmail.com> - 2012-01-15 16:14 -0800
        Re: Problem while doing a cat on a tabbed file with pexpect Cameron Simpson <cs@zip.com.au> - 2012-01-16 12:45 +1100
  Re: Problem while doing a cat on a tabbed file with pexpect Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2012-01-16 02:01 +0000

csiph-web