By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,587 Members | 1,711 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,587 IT Pros & Developers. It's quick & easy.

Codig style: " or """

P: n/a
Hi!

Suppose you're writing a module & writing the
definition of each function in that module in " or
""".
for example:
a) "This function does this & that"
or:
b) """This function does blah blah blah"""

What are the differences between " and """ ?
I'm using gedit & I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes & he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using " or """.

Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.

tnx,
Sara

__________________________________
Do you Yahoo!?
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/
Jul 18 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Sara Khalatbari <sa************@yahoo.com> wrote:
What are the differences between " and """ ?
The triple-quote form lets you write multi-line quoted strings:

"""This function does a lot of neat stuff. It takes
many lines of text to describe what it does.

Multiple paragraphs, even.
"""
To be very honest: I have a very strict boss who looks
for bugs in my codes & he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using " or """.


Show him PEP-8 (http://www.python.org/peps/pep-0008.html). PEP-8, in
turn, references a few other style PEPs. If adopting them wholesale
as authoritative is all you need to keep your PHB happy, go for it.
Jul 18 '05 #2

P: n/a
Sara Khalatbari wrote:
Hi!

Suppose you're writing a module & writing the
definition of each function in that module in " or
""".
for example:
a) "This function does this & that"
or:
b) """This function does blah blah blah"""

What are the differences between " and """ ?
I'm using gedit & I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes & he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using " or """.

Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.


Triple quotes allow you to have quotes inside the string. I tend to use
triple quotes if I'm writing text of any length, that way I dont need to
change anything if I do need to insert a quote. I dont think its a
matter of coding style, its purely a practical issue. If your PHB
insists on consistency, I would just use """
Will McGugan

--
http://www.willmcgugan.com
"".join( [ {'*':'@','^':'.'}.get(c,None) or chr(97+(ord(c)-84)%26) for c
in "jvyy*jvyyzpthtna^pbz" ] )
Jul 18 '05 #3

P: n/a
Sara Khalatbari wrote:
Hi!

Suppose you're writing a module & writing the
definition of each function in that module in " or
""".
for example:
a) "This function does this & that"
or:
b) """This function does blah blah blah"""

What are the differences between " and """ ?
I'm using gedit & I wanna know a bit about coding
style.

To be very honest: I have a very strict boss who looks
for bugs in my codes & he insists to know exactly
which 'CODING STYLE AUTHORITATIVE SOURCE' I've based
my coding style on when using " or """.

Can anybody out there give me some hint?
Can anybody tell me where to find a document on python
coding style.


PEP 8:

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

and for docstrings, PEP 257:

http://www.python.org/peps/pep-0257.html

which says:

For consistency, always use """triple double quotes""" around docstrings.

STeVe
Jul 18 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.