Codig style: " or """

S

Sara Khalatbari

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/
 
R

Roy Smith

Sara Khalatbari said:
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.
 
W

Will McGugan

Sara said:
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
 
S

Steven Bethard

Sara said:
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
 

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

Forum statistics

Threads
474,234
Messages
2,571,179
Members
47,811
Latest member
GregoryHal

Latest Threads

Top