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


Groups > comp.lang.python > #48883 > unrolled thread

n00b question on spacing

Started by"Yves S. Garret" <yoursurrogategod@gmail.com>
First post2013-06-21 17:17 -0400
Last post2013-06-21 21:47 +0000
Articles 2 — 2 participants

Back to article view | Back to comp.lang.python


Contents

  n00b question on spacing "Yves S. Garret" <yoursurrogategod@gmail.com> - 2013-06-21 17:17 -0400
    Re: n00b question on spacing John Gordon <gordon@panix.com> - 2013-06-21 21:47 +0000

#48883 — n00b question on spacing

From"Yves S. Garret" <yoursurrogategod@gmail.com>
Date2013-06-21 17:17 -0400
Subjectn00b question on spacing
Message-ID<mailman.3669.1371849457.3114.python-list@python.org>

[Multipart message — attachments visible in raw view] — view raw

Hi, I have a question about breaking up really long lines of code in Python.

I have the following line of code:
log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'],
settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider)

Given the fact that it goes off very far to the right on my screen is not
terribly
pleasing to my eyes (and can be rude for other developers).

I was thinking of splitting it up like so:
log.msg("Item wrote to MongoDB database %s/%s"
  %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']),
  level=log.DEBUG, spider=spider)

Is this ok?  Are there any rules in Python when it comes to breaking up
long lines of
code?

[toc] | [next] | [standalone]


#48884

FromJohn Gordon <gordon@panix.com>
Date2013-06-21 21:47 +0000
Message-ID<kq2hkq$4v7$1@reader2.panix.com>
In reply to#48883
In <mailman.3669.1371849457.3114.python-list@python.org> "Yves S. Garret" <yoursurrogategod@gmail.com> writes:

> Hi, I have a question about breaking up really long lines of code in Python.

> I have the following line of code:
> log.msg("Item wrote to MongoDB database %s/%s" %(settings['MONGODB_DB'],
> settings['MONGODB_COLLECTION']), level=log.DEBUG, spider=spider)

> Given the fact that it goes off very far to the right on my screen is not
> terribly pleasing to my eyes (and can be rude for other developers).

> I was thinking of splitting it up like so:
> log.msg("Item wrote to MongoDB database %s/%s"
>   %(settings['MONGODB_DB'], settings['MONGODB_COLLECTION']),
>   level=log.DEBUG, spider=spider)

> Is this ok?  Are there any rules in Python when it comes to breaking up
> long lines of code?

There are guidelines in the PEP8 document:

http://www.python.org/dev/peps/pep-0008/

Check out the section entitled 'Code lay-out'.

-- 
John Gordon                   A is for Amy, who fell down the stairs
gordon@panix.com              B is for Basil, assaulted by bears
                                -- Edward Gorey, "The Gashlycrumb Tinies"

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web