n00b question on spacing

Y

Yves S. Garret

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

John Gordon

In said:
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'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,981
Messages
2,570,188
Members
46,731
Latest member
MarcyGipso

Latest Threads

Top