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


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

Re: n00b question on spacing

Started byPeter Otten <__peter__@web.de>
First post2013-06-22 07:46 +0200
Last post2013-06-22 07:46 +0200
Articles 1 — 1 participant

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

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: n00b question on spacing Peter Otten <__peter__@web.de> - 2013-06-22 07:46 +0200

#48915 — Re: n00b question on spacing

FromPeter Otten <__peter__@web.de>
Date2013-06-22 07:46 +0200
SubjectRe: n00b question on spacing
Message-ID<mailman.3686.1371879937.3114.python-list@python.org>
Yves S. Garret wrote:

> 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?

You can move the goal posts and change your API (to one similar to the 
logging module in the standard library, for example):

log.debug(
    "Wrote item to MongoDB database %s/%s",
    settings["MONGODB_DB"],
    settings["MONGODB_COLLECTIONS"],
    spider=spider)

[toc] | [standalone]


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


csiph-web