Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #7563
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!selfless.tophat.at!newsfeed.xs4all.nl!newsfeed6.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <tycho@tycho.ws> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.000 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'newbie': 0.03; 'string.': 0.04; 'subject:two': 0.07; 'python': 0.08; '+0200,': 0.09; 'long"': 0.09; 'subject:string': 0.09; 'this:': 0.10; '>>>': 0.12; 'def': 0.12; 'received:209.85.214.174': 0.14; 'received:mail- iw0-f174.google.com': 0.14; 'wrote:': 0.14; '"copyright",': 0.16; '"credits"': 0.16; '"license"': 0.16; '[gcc': 0.16; 'indent': 0.16; 'linux2': 0.16; 'literals': 0.16; 'subject:lines': 0.16; 'subject:split': 0.16; 'cc:addr:python-list': 0.17; 'mon,': 0.17; 'header:In-Reply-To:1': 0.21; 'cc:2**0': 0.22; 'cc:no real name:2**0': 0.23; 'subject:code': 0.23; 'code': 0.24; '"this': 0.25; 'index': 0.25; 'string': 0.26; "i'm": 0.27; 'received:209.85.214': 0.28; '(as': 0.29; 'all,': 0.30; 'cc:addr:python.org': 0.30; '"but': 0.30; 'print': 0.31; "i've": 0.33; '...': 0.34; 'question': 0.34; 'there': 0.35; 'header:User- Agent:1': 0.35; 'here,': 0.35; 'charset:us-ascii': 0.36; 'received:google.com': 0.37; 'something': 0.37; 'received:209.85': 0.37; 'pretty': 0.37; 'received:128': 0.38; 'but': 0.38; 'subject:: ': 0.38; 'perhaps': 0.39; 'received:209': 0.39; 'really': 0.40; 'more': 0.60; 'huge': 0.62; 'here': 0.66; 'spaces': 0.73; 'subject:long': 0.93 |
| Date | Mon, 13 Jun 2011 16:55:10 -0500 |
| From | Tycho Andersen <tycho@tycho.ws> |
| To | Tracubik <affdfsdfdsfsd@b.com> |
| Subject | Re: split long string in two code lines |
| References | <4df681ae$0$2694$4fafbaef@reader1.news.tin.it> |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Content-Disposition | inline |
| In-Reply-To | <4df681ae$0$2694$4fafbaef@reader1.news.tin.it> |
| User-Agent | Mutt/1.5.21 (2010-09-15) |
| 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.198.1308002118.11593.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 82.94.164.166 |
| X-Trace | 1308002119 news.xs4all.nl 49182 [::ffff:82.94.164.166]:51953 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.python:7563 |
Show key headers only | View raw
On Mon, Jun 13, 2011 at 11:31:29PM +0200, Tracubik wrote: > Hi all, > > newbie question here > > how can i write code like this: > > 1 def foo(): > 2 for index in ... > 3 for plsdoit in ... > 4 print "this is a very long string that i'm going to > write 5 here, it'll be for sure longer than 80 columns" > > > the only way i've found is to use the "/", but than i've to write > something like this: Perhaps you mean '\'? > > 1 def foo(): > 2 for index in ... > 3 for plsdoit in ... > 4 print "this is a very long string that i'm going to/ > 5 write here, it'll be for sure longer than 80 columns" > > what i don't really like is that line 5 is not indented. if i indent > it, the spaces will be counted as spaces of the string. > > Is there a better way to split the string? There is! Python (as C) concatenates string literals with nothing in between them. Python 2.6.2 (r262:71600, Jun 8 2009, 11:11:42) [GCC 4.3.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> def foo(): ... print "this is not such a huge line " \ ... "but it's still pretty long" ... >>> foo() this is not such a huge line but it's still pretty long \t
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
split long string in two code lines Tracubik <affdfsdfdsfsd@b.com> - 2011-06-13 23:31 +0200
Re: split long string in two code lines darnold <darnold992000@yahoo.com> - 2011-06-13 14:51 -0700
Re: split long string in two code lines Terry Reedy <tjreedy@udel.edu> - 2011-06-13 23:55 -0400
Re: split long string in two code lines Tycho Andersen <tycho@tycho.ws> - 2011-06-13 16:55 -0500
Re: split long string in two code lines Redcat <redcat@catfolks.net> - 2011-06-13 22:21 +0000
Re: split long string in two code lines Tim Chase <python.list@tim.thechases.com> - 2011-06-13 17:33 -0500
Re: split long string in two code lines Chris Angelico <rosuav@gmail.com> - 2011-06-14 08:38 +1000
Re: split long string in two code lines Tim Chase <python.list@tim.thechases.com> - 2011-06-13 18:03 -0500
Re: split long string in two code lines Chris Angelico <rosuav@gmail.com> - 2011-06-14 09:11 +1000
csiph-web