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


Groups > comp.lang.python > #80423

Re: What is rstrip() in python?

References <c939252e-673b-4cd2-9399-76753a7dd3f7@googlegroups.com>
Date 2014-11-09 22:28 +1100
Subject Re: What is rstrip() in python?
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.15596.1415532518.18130.python-list@python.org> (permalink)

Show all headers | 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