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


Groups > comp.lang.python > #80423

Re: What is rstrip() in python?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.009
X-Spam-Evidence '*H*': 0.98; '*S*': 0.00; 'skip:[ 20': 0.04; 'here?': 0.09; 'iterate': 0.09; 'rows': 0.09; 'cc:addr:python-list': 0.11; 'code?': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'interpreter,': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'import': 0.22; 'python?': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'message-id:@mail.gmail.com': 0.30; 'piece': 0.31; 'file': 0.32; 'know.': 0.32; 'maybe': 0.34; 'received:google.com': 0.35; 'subject:?': 0.36; 'should': 0.36; 'nov': 0.38; 'pm,': 0.38; 'does': 0.39; 'tell': 0.60; '10:11': 0.84; 'curs': 0.84; 'to:none': 0.92
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=Rmz98R+I6iO8ZGz/9LqsxGkKVkFsvNTHQGTClY51VXo=; b=LMCawpqYL226ppJUNguhTKabX5Onbg8amkOZA+PhHgx3bljw2X1Fdv0N/WbnLgRQVt fmO0OyIdFSlxnqZ101Ilx8aQ5Sye6nfc+bb/1m1ws7f0TLPpjDmNF1+1E4KN28ghJIha CnLFYG7rq6x2UdLi9YDcpPqJc+f8cYCyzLrZO0dDGosDrLIcHbMFLYiIDsgxI/WZXA27 O/kNO9Amwkh2CnGwyfMumrEs8F5t6HZ0uECTBnag7r3p7H1NPZVnXYZ4lbwV2V7WG+Qc Td4GMqJoNNaQ1SutD+Kofv43KMVqKZEi+dHAGvufmgF6tvHvkYkfr1Nm/V21BevpBqh6 woqg==
MIME-Version 1.0
X-Received by 10.42.64.143 with SMTP id g15mr1725075ici.59.1415532509165; Sun, 09 Nov 2014 03:28:29 -0800 (PST)
In-Reply-To <c939252e-673b-4cd2-9399-76753a7dd3f7@googlegroups.com>
References <c939252e-673b-4cd2-9399-76753a7dd3f7@googlegroups.com>
Date Sun, 9 Nov 2014 22:28:29 +1100
Subject Re: What is rstrip() in python?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
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 <https://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 <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15596.1415532518.18130.python-list@python.org> (permalink)
Lines 27
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415532518 news.xs4all.nl 2937 [2001:888:2000:d::a6]:50439
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80423

Show key headers only | View raw


On Sun, Nov 9, 2014 at 10:11 PM,  <satishmlmlml@gmail.com> wrote:
> What is rstrip() in python?
>
> What does it do in the following piece of code?
>
> import sqlite3
> conn = sqlite3.connect('dbase1')
> curs = conn.cursor()
>
> file = open('data.txt')
> rows = [line.rstrip().split(',') for line in file]

Do you know what type of object 'line' is here? Do you know what you
get when you iterate over a file?

Get an object of that type in the interactive interpreter, maybe like this:

file = open('data.txt')
line = next(file)

Then you can find out about its methods:

help(line.rstrip)

That should tell you what you want to know.

ChrisA

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


Thread

What is rstrip() in python? satishmlmlml@gmail.com - 2014-11-09 03:11 -0800
  Re: What is rstrip() in python? Chris Angelico <rosuav@gmail.com> - 2014-11-09 22:28 +1100
  Re: What is rstrip() in python? Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-09 23:57 +1100
  Re: What is rstrip() in python? Mark Lawrence <breamoreboy@yahoo.co.uk> - 2014-11-09 14:17 +0000
  Re: What is rstrip() in python? Terry Reedy <tjreedy@udel.edu> - 2014-11-09 12:46 -0500
  Re: What is rstrip() in python? Joel Goldstick <joel.goldstick@gmail.com> - 2014-11-09 14:16 -0500
  Re: What is rstrip() in python? Will Acheson <willyach07@gmail.com> - 2014-11-11 11:53 -0800

csiph-web