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


Groups > comp.lang.python > #46916

lstrip problem - beginner question

Newsgroups comp.lang.python
Date 2013-06-04 08:21 -0700
Message-ID <1829efca-935d-4049-ba61-7138015a2806@googlegroups.com> (permalink)
Subject lstrip problem - beginner question
From mstagliamonte <madmaxthc@yahoo.it>

Show all headers | View raw


Hi everyone,

I am a beginner in python and trying to find my way through... :)

I am writing a script to get numbers from the headers of a text file.

If the header is something like:
h01 = ('>scaffold_1')
I just use:
h01.lstrip('>scaffold_')
and this returns me '1'

But, if the header is:
h02: ('>contig-100_0')
if I use:
h02.lstrip('>contig-100_')
this returns me with: ''
...basically nothing. What surprises me is that if I do in this other way:
h02b = h02.lstrip('>contig-100')
I get h02b = ('_1')
and subsequently:
h02b.lstrip('_')
returns me with: '1' which is what I wanted!

Why is this happening? What am I missing?

Thanks for your help and attention
Max

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


Thread

lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:21 -0700
  Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:24 -0700
  Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:25 -0700
    Re: lstrip problem - beginner question Fábio Santos <fabiosantosart@gmail.com> - 2013-06-04 16:41 +0100
      Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:49 -0700
        Re: lstrip problem - beginner question Mark Lawrence <breamoreboy@yahoo.co.uk> - 2013-06-04 17:01 +0100
        Re: lstrip problem - beginner question Dave Angel <davea@davea.name> - 2013-06-04 17:48 -0400
  Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:28 -0700
  Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:29 -0700
  Re: lstrip problem - beginner question MRAB <python@mrabarnett.plus.com> - 2013-06-04 16:48 +0100
    Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 08:53 -0700
  Re: lstrip problem - beginner question Peter Otten <__peter__@web.de> - 2013-06-04 17:52 +0200
  Re: lstrip problem - beginner question John Gordon <gordon@panix.com> - 2013-06-04 15:55 +0000
    Re: lstrip problem - beginner question mstagliamonte <madmaxthc@yahoo.it> - 2013-06-04 09:06 -0700
  Re: lstrip problem - beginner question Larry Hudson <orgnut@yahoo.com> - 2013-06-04 21:53 -0700

csiph-web